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

16th Apr '163 of your Earth minutes

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


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.)

  1. 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:
  2. Make sure you install/update to the latest stable version of node.js. I’m running the 4.x branch.
  3. Make npm a global package so you can update that separately to node:
    **sudo npm install npm -g (**as per npm docs)
  4. Install gulp:
    sudo npm install -g gulp-cli (this command will suffice)
  5. You may need to run this command to grab some extra Elixir dependencies:
    npm install babel-preset-es2015 babel-preset-react
    As Nate Ritter has suggested, install this globally (thanks Nate):
    npm install -g babel-preset-es2015 babel-preset-react
  6. Update composer (obvs you’ve got composer installed):
    composer self-update
  7. Install/update the Laravel installer:
    composer global [require/update] “laravel/installer”
  8. 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)
  9. 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.
  10. Run the Spark install where you want your project to live:
    spark new [your-spark-project]
  11. Create a new database for your app
  12. 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
  13. 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
  14. Run the Laravel database migrations. In your app’s root:
    php artisan migrate
  15. 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)

Hat tip to the awesome folks in the Laravel Slack team (particularly coderleo and tommytompkins)

You may experience the missing Elixir dependencies in Homestead. Check out this discussion on Laracasts.

#notadesigner • Please don't © me

Want to support my work? Please consider sponsoring me on Spred