Skip to content

Instantly share code, notes, and snippets.

@pitchinnate
Created September 14, 2016 20:48
Show Gist options
  • Select an option

  • Save pitchinnate/acb3bdf2ae593b91bf4f7086c575bafe to your computer and use it in GitHub Desktop.

Select an option

Save pitchinnate/acb3bdf2ae593b91bf4f7086c575bafe to your computer and use it in GitHub Desktop.

Requirements

In order to run this locally you will need the following tools/programs:

Global Installs

For php/composer install the following packages globally so they can be used anywhere:

composer global require "phpunit/phpunit"
composer global require "laravel/installer"

Aliases

If you are using cmder I highly recommend setting up some aliases that will make your life a lot easier. {CmderDirectory}\config\user-aliases.cmd add the following lines:

gs=git status
aa=git add --all
push=git push
pull=git pull --rebase
test=phpunit
testreport=php -c .\php-xdebug.ini C:\Users\{USERNAME}\AppData\Roaming\Composer\vendor\phpunit\phpunit\phpunit --coverage-html ./storage/logs/phpunit
testu=phpunit --testsuite unit
testf=phpunit --testsuite functional
testa=phpunit --testsuite functional
cleandb=php artisan migrate:refresh && php artisan db:seed

Running Package Managers

From the project directory you will need to make sure you have all frontend dependencies (npm) as well as backend dependencies (composer). The following commands will need to ran:

composer install
npm install

Local Environment - Database

First you will need to create your local version of your .env file. This goes in the root directory of the project code. This allows you to set environment variables without having to worry about what web server you are using. You can copy the contents of /.env.example to your /.env file. Make sure you update your database credentials to connect to your local database server. Set your database as an empty database then use migrations to create all tables.

Database Migrations and Seeds

To run database migrations simple run the artisan command migrate from the root directory of the project. If you want to use seed data run the artisan command db:seed command from the root directory of the project.

php artisan migrate
php artisan db:seed

Local Environment - Web Server

You have two options for running a web server locally. You can either run the server from the command line or you can use something like WAMP Server (http://www.wampserver.com/en/). I personally use Wamp Server 64bit with PHP 7.0.

Running Web Server via Command Line

From the project directory you will simply need to run php artisan serve. By default it will be running on localhost:8000, so you should be able to go to http://localhost:8000 in your browser.

Running Web Server via Wamp Server

First I normally setup a host record for a dev domain name, something like mroc.local. Open up your windows host file which can be found at C:/Windows/System32/drivers/etc/hosts. Add a line that looks like this:

127.0.0.1    mroc.local

In your wamp directory look for a directory called /alias, I normally create a vhost in here by creating a sites.conf file. Mine looks like this:

<VirtualHost *:80>
	ServerName mroc.local
	DocumentRoot c:/wamp64/www/mroc/public
</VirtualHost>

Modify your DocumentRoot if your code is in a different location. After you have added this make sure you restart apache for it to pick up the new .conf file. After this you should be able to visit http://mroc.local in your browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment