The 10 (ok, 15) steps to setup your first Laravel Spark app

a.k.a. “The long way”

Edit: Since writing this, Laravel Valet has been launched. I haven’t tried it yet, but if you use a Mac it looks like an excellent foundation for your development environment and ideal for setting up Spark installs (among many others) without the overhead of Homestead and looks way easier to use than Apple’s built-in AMP setup or MAMP. Nice work Taylor Otwell and Adam Wathan.

I wanted to try Spark, but I’m not ready for Homestead. To be honest that would be the better way to go all round as it’s pre-packaged with everything you need.

But that doesn’t work for everyone and I wanted to get it running without changing my setup. I also wanted to use the Spark installer not just the download method.

I found the current docs fall a little short on this at the moment. I’m sure they’ll be updated. But I just jumped straight into the install and hit a few errors along the way.

Here are some of the hurdles I experienced on my install journey:

Class Illuminate\Foundation\ComposerScripts is not autoloadable, can not call post-installcmd script

And:

gulp not installed

And some Browserify error at the end. Which all basically come down to either missing or outdated components. So here’s an install run list for you to follow which *should* get you there in no time. Hopefully it will save you a few minutes.

(I’m running MAMP with PHP 7, but there’s no reasons why this process shouldn’t apply in most other working setups.)

The docs say under ‘Requirements’: Composer, Laravel 5.2, Laravel Elixir and Bootstrap LESS. If you use the Spark installer though, all you really need to do is set up Elixir. Here’s an adapted version: Make sure you install/update to the latest stable version of node.js. I’m running the 4.x branch. Make npm a global package so you can update that separately to node:

sudo npm install npm -g (as per npm docs) Install gulp:

sudo npm install -g gulp-cli (this command will suffice) You may need to run this command to grab some extra Elixir dependencies:

npm install babel-preset-es2015 babel-preset-react

OR

As Nate Ritter has suggested, install this globally (thanks Nate):

npm install -g babel-preset-es2015 babel-preset-react Update composer (obvs you’ve got composer installed):

composer self-update Install/update the Laravel installer:

composer global [require/update] “laravel/installer” Get Spark (you need to register, login, add a payment method, buy a licence and, if you want to use the Spark installer, generate an API token) Set up the Spark installer — this is a multi-step process all of its own that’s not well covered in the docs yet if you’re not used to working with GitHub etc. I will cover this soon. Run the Spark install where you want your project to live:

spark new [your-spark-project] Create a new database for your app Set up a virtual host and point the site root at the /path/to/project/[your-spark-project]/public and create an appropriate hosts file entry for it Spark installs expecting to be inside Homestead, so the .env is configured for that. You’ll need to change the APP_URL, DB_DATABASE, DB_USERNAME and DB_PASSWORD settings according to your setup Run the Laravel database migrations. In your app’s root:

php artisan migrate Load up your new dev vhost domain in the browser and you should see this:

Hello, Spark

All done. Go play! (and watch the Laracasts)