Get started with Laravel — the PHP web framework for 2016

Laravel 5 released early in 2015

Laravel is a relatively new web framework (2011) for running modern PHP applications. The framework borrows the best concepts from Ruby On Rails with a fast runtime. There is a large developer community because it allows us to be productive and make stuff quickly with minimal hassle. This tutorial will take you from zero to web app in a few minutes!

Install composer

The first step is to getting started is to install composer on your system. I’m running OSX. You can read here about how composer saved the PHP programming language. Composer is a package manager for PHP, making it possible to write many reusable modules. Node.js has npm, Ruby has gems, PHP has composer.

There are options on the install instructions for local and global installs. Install composer globally on your machine.

$ curl -sS | php
$ mv composer.phar /usr/local/bin/composer
$ composer
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
Composer version 1.0-dev (d6ae9a0529e1f39c4c7f9b2f29fff019d79cd1fb) 2015-12-22 20:44:41

Install laravel

Next we will use the composer package manager to install the laravel installer. It is like installception.

Here’s the command to install laravel with composer.

$ composer global require "laravel/installer"

Next we have to add composer to our computer’s PATH. That means we need to make the “laravel” command available on the terminal. If you are using bash add

export PATH=”$PATH:$HOME/.composer/vendor/bin”

to the ~/.bashrc file. You can do this by opening the file in a text editor:

$ sublime ~/.bashrc


$ nano ~/.bashrc

Then add the “export …” line to the file that opens up. Save your changes, restart terminal and you will be able to run the “laravel” command and see output.

$ laravel
Laravel Installer version 1.3.1
command [options] [arguments]

If you have trouble adding to bashrc check out this post. If you are using Oh My ZSH for terminal instead of bash (you would know it) add the line to ~/.zshrc instead of ~/.bashrc.

Create your first Laravel app

Laravel new command will create a new project. The command below creates a folder called “laravel-starter” with a new laravel project inside.

$ laravel new laravel-starter
$ cd laravel-starter
$ php artisan serve
Laravel development server started on http://localhost:8000/

Open your web browser to http://localhost:8000/ and you’ll see…

Congrats! You are running a laravel web app! Stay tuned for more posts about adding functionality to your laravel app.

If you liked this tutorial…

Check out a few of my most popular posts from 2015:

Make a deck of cards with Django

Django is a python a framework for making web applications. This tutorial will get you up and running with the framework.

Handle all authentication with Node, Angular and Stormpath

Log users in and out with Google’s angular.js framework, server side javascript and the Stormpath user management service (SaaS).

Ruby On Rails — Introduction for the total n00b

Get started with Ruby On Rails, another web framework! This one is made out of the Ruby programming language (go figure).