Setting up Laravel Spark for local development
Spark is a Laravel package that provides scaffolding for a SaaS application and includes billing, subscriptions, authentication, payment, etc.
The instructions below are for setting up a Laravel Spark application (Spark v10.0) for local development on MacOS.
I’m assuming the following:
- you already have a local development environment suitable for running Laravel applications. For more information check out the Laravel docs
- you have purchased a licence and have received your token
Before we start, ensure you are running PHP 7.3
At time of writing (May, 2020) the Spark installer fails on PHP 7.4.
1. Install or upgrade the Laravel Installer
composer global require laravel/installer
Ensure you have >= 2.3.0 of the Laravel Installer installed.
2. Install the Spark Installer
git clone https://github.com/laravel/spark-installer.git
Change into the spark-installer directory and run composer install
Next, add the Spark Installer directory to your PATH
export PATH=$PATH:/path/to/spark-installer
3. Run the Spark Installer
Add your token (from purchasing a Spark licence)
spark register <<token>>
Next, run the Spark installer
Note: it will create a new directory in whatever location you run the command
spark new <<project name>>
4. Configure application settings
Edit your .env
file and add your projects settings, especially DB credentials.
Then, run the Spark migrations
php artisan migrate
As per the Spark docs, link the storage directory with
php artisan storage:link
You should now be able to load the site in your browser!
5. Accessing the developer “Kiosk” area of the site
Edit the app/Providers/SparkServiceProvider.php
file and add your email address to the $developers
array.
Then, use the Register feature on the site to create an account, with that same email address.
E.g. https://local-spark-domain.com/register
Once this account has been created you’ll be able to see the Kiosk option on the top right menu under your Profile name.
Note: You can find all the Spark URLs via the routes file spark/src/Http/routes.php
More Spark tutorials