Install Laravel Spark on workspace

Install Laravel Spark on workspace

Hope this helps someone. After two days of toil I finally got a spark project up on a workspace here are the steps I took. This assumes you have already bought a Spark license at

  1. Create the c9 workspace.
  2. Because I ultimately want to deploy to a digital ocean droplet and the latest laravel / spark requires PHP >5.6 you need to update php on your c9 workspace. I found using php brew works the best:  ( )  You can use phpbrew on Cloud9. I found that the standard installation process works fine, just run the commands below. We first install the libmcrypt-dev package to avoid running into dependency issues during the build: 
    $ sudo apt-get update
    $ sudo apt-get install libmcrypt-dev

    Next, we download phpbrew and move it to /usr/local/bin:

    $ curl -L -O
    $ chmod +x phpbrew
    $ sudo mv phpbrew /usr/local/bin/
    $ phpbrew init
    # add this to your ~/.bashrc:
    $ [[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc
    $ phpbrew lookup-prefix ubuntu

    Once set up, we install and load PHP 7:

    $ phpbrew install 7.0 +default
    $ phpbrew switch php-7.0.1
    $ phpbrew use php-7.0.1
    $ php -v
    PHP 7.0.1 (cli) (built: Dec 29 2015 22:04:43) ( NTS )
    Copyright (c) 1997-2015 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
  3. Next make a phpinfo.php file in your workspace root if you fire up your workspace you will notice that apache still think php is 5.5. You need to disable the old php module and enable the new php 7.0 module . From Roland on   I had the same problem. You have to disable the php5 module in apache2 and then enable the php7 module:
    $ sudo a2dismod php5
    $ sudo a2enmod php7.0

    When I did this I got an error ‘could not parse envvars’ but I solved this by temporarily renaming this file in the /etc/apache2 directory. Then restart apache.

    If you do not see php7.0 module then do the following:

    $ sudo add-apt-repository ppa:ondrej/php -y
    $ sudo apt-get update -y
    $ sudo apt-get install php7.0-curl php7.0-dev php7.0-gd php7.0-intl php7.0-mcrypt php7.0-json php7.0-mysql php7.0-opcache php7.0-bcmath php7.0-mbstring php7.0-soap php7.0-xml
    $ sudo apt-get install libapache2-mod-php7.0 -y
  4.  If you going to use Spark then you also need PHP Zip so install
    $ sudo apt-get install php7.0-zip
  5. Clone the Laravel Spark Installer into your workspace root
  6. Add Spark to your workspace path.
    $ vim ~/.bashrc

    Add these lines at the end of your file

    # Laravel Installer
    export PATH="$PATH:$HOME/.composer/vendor/bin"
    # Spark Installer
    export PATH="$PATH:$HOME/workspace/spark-installer"
  7. Now you are ready to install Spark. Got into your spark-installer directory and run composer install. That should install spark and all its dependencies.
    composer install
  8. Register Spark, got to and login. In your user settings go to the API page and create a new API token.
  9. From here you can follow the install instructions in Spark’s documentation
  10. Remember you have to create your database and database user and set them in your project .env before you can run php artisan migrate.
  11. The only other problem I had was that the npm intall for my spark project was failing. So to fix it I upgraded nodejs to v 6.4. You can do this by running
    $ nvm install 6.4
    $ nvm use 6.4

    Then run your npm install

    $ npm install --save
This entry was posted in Uncategorized. Bookmark the permalink.