# Laravel Installation

Pre-Requisites:

You would need PHP installed on your system. If you don't have PHP installed, you can refer to the installation documentation for your specific Operating System here: http://php.net/manual/en/install.php.

You would also need Composer installed. If you don't have Composer, you can get it from here: https://getcomposer.org/doc/00-intro.md

Once you have PHP and Composer installed, head over to the NodeJS website and install a Node version greater v6.3.1: https://nodejs.org/en/

You will also need VirtualBox and Vagrant installed as we will be using Homestead for developing Laravel apps.

You can download VirtualBox from here: https://www.virtualbox.org/

You can download Vagrant from here: https://www.vagrantup.com/


For Windows users only:

If you are on Windows, you need to setup your system to be able to compile Node native modules. There are two options available:

  • Option 1 (recommended): Install all the required tools and configurations using Microsoft's windows-build-tools for compiling Node modules. To do that just run: npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator).

  • Option 2: Install tools and configuration manually:

    • Visual C++ Build Environment:

      • Option 1: Install Visual C++ Build Tools using the Default Install option.

      • Option 2: Install Visual Studio 2015 (or modify an existing installation) and select Common Tools for Visual C++ during setup. This also works with the free Community and Express for Desktop editions.

    • Install Python 2.7 (v3.x.x is not supported), and run npm config set python python2.7

    • Launch cmd, npm config set msvs_version 2015


Installation

Once you have setup Node, PHP and Composer, open a terminal/command prompt and change the current working directory to the laravel directory in your downloaded Rubix folder like so (on Windows you would need to replace the backward slash "/" with the forward slash "\"):

$ cd rubix/laravel

As you can see, the laravel directory has two sub-directories: A laravel seed named laravel-seed and a simple Todo list example app named laravel-example.

We will be re-creating the laravel-example app, which, you can use as a reference for this tutorial. Please clone the laravel-seed directory and rename the new copy to laravel-todolist. (The installation steps for laravel-example is the same as below so we won't be repeating it here)

$ cp -rf laravel-seed laravel-todolist

Change the working directory to laravel-todolist and install all the project dependencies:

$ cd laravel-todolist
$ composer install --no-scripts

Then run the command corresponding to the platform you are developing on:

  • Mac / Linux:

    $ php vendor/bin/homestead make
  • Windows:

    $ vendor\bin\homestead make

Once you have done that run the following command to generate a unique key for your app:

$ php artisan key:generate

Install Node modules:

$ npm install

You may get some deprecation warnings as well as peerDependency warnings in your terminal while/after the NPM installation. Please ignore those warnings.

Once you have installed the necessary NPM dependencies, start the Virtual Machine (the compile/build time will be approximately 15-20 minutes on the first run as the VM will install v8js for React server-side rendering. Subsequent launches will be in seconds):

$ vagrant up

Once the VM is setup, run:

$ npm run dev -s

to launch the Webpack development server. Then navigate to http://localhost:8000 to view your Laravel + React app. You should see a dashboard with "Hello, World!" displayed in your browser.

Now that the basic setup is complete, click the "Next" button below to start the tutorial.