Skip to main content

Local development

Setup - Up and running in less than 5 minutesโ€‹

Depending on your preference, you can either use Docker Sail or Laravel Herd to set up a local development environment for SaaSykit.

  1. Fork/Clone the SaaSykit repository

    There are two ways you can use the SaaSykit repository; clone it locally and push it to your own repository, or fork the repository to your GitHub account.

    Github has a limitation that allows you to only clone a repository once. This means that if you're planning to use SaaSykit to build multiple projects, or if you want to both use "SaaSykit" and "SaaSykit Tenancy" (which is a fork of SaaSykit) at the same time, you're better off cloning the SaaSykit repository and pushing it to your own repository.

    • Clone the SaaSykit repository to your local machine:

      git clone https://github.com/saasykit/saasykit.git

      For SaaSykit Tenancy, you can clone the repository using the below command:

      git clone https://github.com/saasykit/saasykit-tenancy.git
      • Change into the project directory:

        cd saasykit

        For SaaSykit Tenancy, you can change into the project directory using the below command:

        cd saasykit-tenancy
    • Rename the default "remote" to "upstream" (the source youโ€™re tracking):

      git remote rename origin upstream
      • Create a New Repository on you GitHub account for your new project

      • Add a new "remote" called "origin" to (your own repository):

        git remote add origin https://github.com/your-username/your-repo.git
      • Push the code to your repository:

        git push -u origin main

    Fork the repositoryโ€‹

    If you decide to go this way, fork the SaaSykit repository to your GitHub account. You can do this by clicking the "Fork" button in the top right corner of the SaaSykit repository or SaaSykit Tenancy repository.

    Once you have forked the repository, you can clone it to your local machine using the below command:

    git clone [your-forked-repository-url]
  2. Set up the local development environment

Sail is a light-weight command-line interface for interacting with Laravel's default Docker development environment. Sail provides a great starting point for building a Laravel application using PHP, MySQL, and Redis without requiring prior Docker experience. You will need to have Docker installed on your machine to use Sail.

If you prefer to watch a video tutorial, you can watch the below video to get started: (all the commands used in the video are also listed below):

Once you get docker installed on your machine, you can follow the below steps to get started with SaaSykit.

  1. Change into the project directory (if you haven't already)

    cd [your-forked-repository-name]
  2. Install composer dependencies

    composer install --ignore-platform-reqs --no-interaction --no-scripts --prefer-dist
  3. Copy .env.example to .env

    cp .env.example .env
  4. Open the .env file and make sure that the ports defined under # local development settings are not in use by any other application on your machine. If they are, you can change them to any other port of your choice.

  5. Run the below command to start the docker containers

    ./vendor/bin/sail up -d
  6. Generate app secret

    ./vendor/bin/sail artisan key:generate
  7. Run migrations

    ./vendor/bin/sail artisan migrate
  8. Run seeders

    ./vendor/bin/sail artisan db:seed
  9. Link storage

    ./vendor/bin/sail artisan storage:link
  10. Install npm dependencies

    ./vendor/bin/sail npm install
  11. Build assets

    ./vendor/bin/sail npm run build
  12. Run the NPM (vite) watcher

    ./vendor/bin/sail npm run dev

That's it! ๐ŸŽ‰ Open the browser and go to http://localhost:8080 (or change the port here if you choose another port in .env.). You should see the SaaSykit home page.

Creating an Admin Userโ€‹

You can create an admin user by running the below command:

./vendor/bin/sail artisan app:create-admin-user

With that use you can access the admin panel by going to /admin and logging in with the credentials you just created.

Demo dataโ€‹

SaaSykit comes with demo data that you can use to test the application and see how things look and work. The demo data includes products, plans, discounts, blog posts, and users, etc.

To install the demo data, you can run the below command:

./vendor/bin/sail artisan db:seed "Database\Seeders\Demo\DemoDatabaseSeeder"

Development Resourcesโ€‹

SaaSykit is based on the awesome Laravel framework. If you are new to Laravel, you can check out the Laravel documentation to get started with Laravel.

If you are already familiar with Laravel, you will easily be able to get started with SaaSykit as it follows the same coding standards and best practices as Laravel.

The admin panel and user dashboard are built using Filament. Filament is a beautiful, modern, and responsive admin panel for Laravel applications.

Keeping your fork up to dateโ€‹

To keep your fork up to date with the original repository, you can follow the below steps:

  1. Add the original repository as a remote

    For SaaSykit use:

    git remote add upstream https://github.com/saasykit/saasykit.git

    For SaaSykit Tenancy use:

    git remote add upstream https://github.com/saasykit/saasykit-tenancy.git
  2. Fetch the branches and commits from the original repository

    git fetch upstream
  3. Merge the changes from the original repository into your local branch

    git merge upstream/main

Then you can push the changes to your forked repository.

tip

It's a good practice to regularly keep your fork up to date with the original repository to get the latest features and bug fixes. This will also help you to avoid/reduce the merge conflicts in case you edited the same files that was updated in the original repository.

Running automated testsโ€‹

SaaSykit comes with an ever-growing set of automated tests that cover the critical components of the application.

While some developers prefer to always run tests against a sqlite database, this might leave some bugs undetected that will be only visible when running against a real database like MySQL or PostgreSQL.

So it's important to configure your automated tests to use the same database type you plan to use in production.

You'll need to edit your .env.testing file to match your local database settings.

For example, if you are using MySQL, you can update the .env.testing file to look like this:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=saasykit_test
DB_USERNAME=YOUR_USERNAME
DB_PASSWORD=YOUR_PASSWORD

For PostgreSQL, you can update the .env.testing file to look like this:

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=saasykit_test
DB_USERNAME=YOUR_USERNAME
DB_PASSWORD=YOUR_PASSWORD
tip

Sometime for certain operating system you might need to switch "localhost" to "127.0.0.1" in the .env.testing file in case the host is not being resolved.

Then you can run the tests using the below command:

./vendor/bin/sail test