Laravel – The PHP Framework For Web Artisans 2

Laravel –The PHP Framework For Web Artisans2

In the last blog, we have covered What is Laravel and its features. I hope everybody has understood that what Laravel is and why we will use it. In this blog, we will learn about Laravel and its components. First of all, we will discuss how to set up Laravel in Local Machines and Live Server.

How to set up Laravel in local machine?

To set up Laravel in local machine we need a web server like Apache, Nginx, IIS, etc which support PHP & if you wish to interact with Database then MySQL, Oracle or MSSQL DB. Alternatively, you can also download any third-party software and install into your local machine (Like XAMPP, WAMPP). After that, download Laravel from its official website or Git Hub. If you download Laravel form its official website then you need to install Composer first. The obvious question to arouse is  “What is Composer”? Composer is an application-level package manager for PHP which provides a sophisticated format for managing dependencies of PHP software and required libraries.  It was developed by Nils Adermann and Jordi Boggiano.

After installing Composer in your local system at first check your local server requirements. If you install Laravel 5.7(Current Version) the requirements are:-

  • PHP >= 7.1.3

  • OpenSSL PHP Extension

  • PDO PHP Extension

  • Mbstring PHP Extension

  • Tokenizer PHP Extension

  • XML PHP Extension

  • Type PHP Extension

  • JSON PHP Extension

Laravel utilizes Composer to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine. Basically, there is a Two-step to install Laravel.

Step 1: Laravel Installer:

At first download the Laravel installer using Composer :

composer global require laravel/installer

Before execute the above command please make sure that Composer’s system wide vendor directory is in your $PATH variable so the laravel executable can be located by your system. This directory may be located in different location depending on which Operating system you are using. Basically the common locations are:
  • macOS: $HOME/.composer/vendor/bin

  • GNU / Linux Distributions: $HOME/.config/composer/vendor/bin

Once it installed by using “Laravel new” command, you will create a fresh Laravel application in the particular directory you specify. For example, Laravel new demo will create a directory named demo. 

So your final command will be like : laravel new demo

Step 2: Using Composer create-project:

Alternatively, you can install Laravel by Composer create-project command in your terminal:

composer create-project –prefer-dist laravel/laravel demo

After installing laravel, it automatically creates an application key. You can change the key by the following command : 

PHP artisan key: generate

Or you can change it manually from .env file. The .env file is located in the root directory of your installed application. Generally C:\\XAMPP\htdocs\demo. After you generate the application you can start or run the application from your local server. If you don’t want to start local application development server formerly known as “Artisan” you can access the folder directly from URL. In that case, it shows the whole directory structure. To create indexing on that particular place you can move the index page from public folder to root folder or you can start a development server of your application by using Artisan.

Php artisan serve

This command will start a development server at http://localhost:8000

Hope, this blog will definitely help you set up Laravel in your local machine