Skip to content

Instantly share code, notes, and snippets.

@kkirsche
Last active December 18, 2015 02:48
Show Gist options
  • Save kkirsche/5713558 to your computer and use it in GitHub Desktop.
Save kkirsche/5713558 to your computer and use it in GitHub Desktop.
Create and Setup new Laravel 4 Project

Install Laravel 4

To install Laravel 4 we will take advantage of composer's create-project ability. We can do this in the following manner:

    composer create-project laravel/laravel LocalDirectoryName

This will install the Laravel project. Where I have put LocalDirectoryName, you can specify the folder name that you would like laravel installed to within the directory.

Next, we have to make sure that everything within Laravel is setup, and ready for us to begin developing our project. The first thing I like to do is ensure that my project has the key setup so all encryptions are safe. Thankfully, Laravel has a function that can generate this key for us.

First, we have to cd into the direct:

    cd LocalDirectoryName

Next, we want to generate the key:

    php artisan key:generate

If this command worked correctly, you will see:

    Application key [32-CHARACTER KEY HERE] set successfully.

With this ready, we want to configure our settings for the application. This can be done in app/config/app.php. Depending on your environement, local development or a production site, you will want to set line 16's 'debug' => true, to a value that suits your environment.

Next, we want to set our Application URL on line 29. For MAMP users, this will often mean appending the port number you are using to connect to the site with to the URL. You may also want to change either the timezone or locale depending on your situation.

With the basic application setup, we want to make sure Laravel can communicate with our database. On line 29 you will be able to set the type of database that you will be using. By default, Laravel 4 uses mysql, but you have these other options:

  • sqlite (SQLite)
  • mysql (MySQL)
  • pgsql (PostgreSQL)
  • sqlsrv (Microsoft SQL Server Driver)

To configure the driver of your choice, you would find their respective settings on the following lines:

  • SQLite — Lines 49–53
  • MySQL - Lines 55–64
  • PostgreSQL - Lines 66-75
  • Microsoft SQL Server - Lines 77–84

With your database setup, you are now ready to begin programming your Laravel application!

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