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 applications secure. Some key features make Laravel more powerful for building large and robust web applications.

Laravel has the following key features which are most required for 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. This step-by-step guide for beginners will help you to install and configure Laravel framework on Windows or Ubuntu servers easily.

Before getting started with 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

1. Download the Composer-Setup.exe file on your system and run the installer. It will install the latest version of Composer.

2. Once the Composer is installed, open the command prompt and type composer command to check the installation status.

windows-10-command-prompt-composer-install-codexworld

Install Composer on Ubuntu

1.Update packages and dependencies:
Before download and install Composer, 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

2. Download and install composer:
Run the following commands to get the latest Composer version. These 4 lines commands will do the 4 things.

  • Download the installer
  • Verify the installer
  • Run the installer
  • Remove the installer
php -r "copy('https://getcomposer.org/installer', '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 the /usr/local/bin directory on Ubuntu.

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

3. To test Composer installation, use the following command:

composer
laravel-tutorial-ubuntu-install-composer-codexworld

Install Laravel on Windows

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

1. Open the Windows command prompt and navigate to the C:\xampp\htdocs directory.

cd C:\xampp\htdocs
windows-10-command-prompt-navigate-xampp-htdocs-codexworld

2. Run the following command to install Laravel in C:\xampp\htdocs\laravel-app directory.

composer create-project laravel/laravel laravel-app

Laravel installation will start, wait for completion.

windows-composer-laravel-install-xampp-codexworld

Install Laravel on Ubuntu

1. 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-app):

laravel new /var/www/html/laravel-app

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

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

Test Laravel Installation on Windows

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

laravel-tutorial-windows-xampp-installation-configuration-codexworld

Laravel development server: You may start Laravel local development server using the following command.

cd laravel-app

php artisan serve
laravel-tutorial-windows-xampp-development-server-codexworld

Test Laravel Installation on Ubuntu

Go to the Laravel project (laravel-app) directory:

cd /var/www/html/laravel-app

Start Laravel development server:

php artisan serve

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

laravel-tutorial-ubuntu-development-url-codexworld

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

laravel-tutorial-windows-ubuntu-installation-configuration-codexworld

Conclusion

Hope this Laravel tutorial for beginners helps you to install and configure the Laravel framework on Windows and Ubuntu server. Follow this step-by-step guide to install Laravel 8 on Xampp. Once installation or configuration is completed, you can go through the next part of the Laravel tutorial.

Do you want to get implementation help, or enhance the functionality of this script? Click here to Submit Service Request

Leave a reply

keyboard_double_arrow_up