Laravel 5.4 tutorial for beginners

Laravel is a poupular PHP framework ,first created in 2011 and always growing in popularity .In 2015 Laravel was the most starred PHP framework on Github .Since its first days ,it has experienced an exponential adoption among PHP developers .

Laravel has a lot of modern features just like the well known Python framework Django .It is also based on Symfony ,one of the greatest PHP framework and is considered by many developers as a lightweight version of Symfony .

In this tutorial ,we are going to focus on the latest version of Laravel which is 5.4 ,released on January 2017 .

Throughout this tutorial or tutorial series ,we are going to build a PHP web application for creating invoices .It is in the same time an application that I need right now and also can be used to demonstrate how many features and constructs of Laravel 5.4 framework work ,from templates and routes to models and database .

First things first .We are going to start by installing Laravel 5.4 on our system but we are not going to cover how to install PHP so this tutorial has some few requirements which are :

A PHP environment installation .

MySQL database system installed .

So you need to have PHP installed on your system ,to check it ,open your terminal on Linux/MAC or command prompt on Windows and type

php -v 

You should get something like this

PHP (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Which means I have PHP 7 installed .

If the command is not recognizable by your system then go ahead and install PHP before continuing with this tutorial .

Now lets install Composer .In case you are wondering ,this is a package/dependency manager for PHP that allows you too pull and automatically install PHP packages (frameworks ,libraries etc.) from a remote registry where other PHP developers publish their packages for everybody to install .For example ,Laravel 5.4 itself can be installed using Composer .

To install Composer ,visit this website then copy the installer script and paste it in your terminal .The installer will download the latest composer.phar
to your current directory.

To run Composer ,type

php composer.phar

From the same directory where you have downloaded the installer script .

You can also make Composer available globally by putting it in a folder that's part of the PATH system variable

On Unix based systems such as Linux and MAC you can do something like that

sudo mv composer.phar /usr/local/bin/composer        

Or without sudo on some systems ,by the way I'm using an Ubuntu system so the commands I enter maybe different on your system .

Now you can run


To use Composer from your terminal .

You can see this getting started guide if you are using Windows

Downloading and installing Laravel 5.4

Using Composer you can install larave 5.4 with just one command

composer global require "laravel/installer" 

Next add $HOME/.config/composer/vendor/bin to your PATH system variable to make laravel available from any directory .

It can be also $HOME/.composer/vendor/bin depending on your system .
export PATH=$PATH:$HOME/.config/composer/vendor/bin    

Now you can type laravel on your terminal to see a list of available commands at your disposal

Creating a new Laravel project

To create a new Laravel 5.4 project ,just type

laravel new MyApp 

You can also use Composer to create a Laravel project without using the laravel utility

composer create-project --prefer-dist laravel/laravel MyApp

Now you can run your local server with

cd MyApp
php artisan serve

You should be able to visit your web app at http://localhost:8000

You can find more instructions about installation on Laravel 5.4 docs


So we have created our fresh Laravel 5.4 project .See you on the next part where we are going to dive into creating database Models for our project .

comments powered by Disqus