Laravel Tutorial for Beginners (Installation & Configuration)

Laravel is an open-source PHP framework, follows the MVC (model–view–controller) pattern. Laravel reduces the time of web development and helps to make web application secure. Some key features make Laravel more powerful for building large and robust web application.

Laravel has the following key features which are most required for the modern web development.

  • Simple, fast routing engine.
  • Powerful dependency injection container.
  • Multiple back-ends for session and cache storage.
  • Query builder and ORM
  • Database agnostic schema migrations.
  • Robust background job processing.
  • Real-time event broadcasting.
  • Authentication
  • Template engine

In this Laravel tutorial, we’ll go through the installation and configuration process of Laravel 5. Our step-by-step guide for beginners will help you to install and configure Laravel framework on Windows or Ubuntu server easily.

Before you start Laravel installation, make sure your server meets the following requirements.

  • PHP >= 5.6.4
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

Laravel uses Composer to manage dependencies. So, before installing Laravel, make sure that the composer is installed in your system.

Install Composer on Windows

  • Download Composer-Setup.exe file on your system and run the installer. It will install the latest version of Composer.
  • Once the Composer is installed, open the command prompt and type composer command to check the installation status.

Install Composer on Ubuntu

  • Update packages and dependencies:
    Before Composer download and install, make sure all the packages are updated and their dependencies are installed.

    Run the following command to update packages:

    sudo apt-get update

    The following dependencies are needed to install.

    • curl – for download Composer
    • php5-cli – for install and run Composer
    • git – used by Composer

    Install all the dependencies by the following command:

    sudo apt-get install curl php5-cli git
  • Download and install composer:

    Run the following commands to get the latest Composer version. This 4 lines commands will do the 4 things.

    • Download the installer
    • Verify the installer
    • Run the installer
    • Remove the installer
    php -r "copy('', 'composer-setup.php');"
    php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"

    Now move composer.phar file to the /usr/local/bin/ directory by running the following command:

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

    Alternatively, you can use the following single line command to download and install Composer in /usr/local/bin directory on Ubuntu.

    curl -sS | sudo php -- --install-dir=/usr/local/bin --filename=composer
  • To test Composer installation, use the following command:

Install Laravel on Windows

Assume that you want to install Laravel on XAMPP server in Windows.

  • Open the Windows command prompt and navigate to the C:/xampp/htdocs directory.
    cd \xampp\htdocs\
  • Run the following command to install Laravel in C:/xampp/htdocs/laravel directory.
    composer create-project laravel/laravel laravel

    Laravel installation will start, wait for complete.


Install Laravel on Ubuntu

Install Via Laravel Installer

At first, download the Laravel installer using Composer:

composer global require "laravel/installer"

Create a fresh Laravel installation in a specific directory (for example, laravel):

laravel new /var/www/html/laravel

Install Via Composer Create-Project
Create a fresh Laravel installation in laravel directory:

sudo composer create-project laravel/laravel /var/www/html/laravel

Test Laravel Installation on Windows

Run the Laravel project URL on the browser (http://localhost/laravel/public/). If Laravel installed successfully on Windows server, the below screen will appear.


Test Laravel Installation on Ubuntu

Go to the Laravel project (laravel) directory:

cd /var/www/html/laravel

Start Laravel development server:

php artisan serve

The terminal will show the below screen, copy the development server URL.


Run the development URL on the browser (http://localhost:8000/). If Laravel installed successfully on Ubuntu server, the following screen will appear.


Related Articles

Comments 0