running Laravel on local server
Laravel, PHP, Programming

How to configure Laravel application on localhost

Laravel is a popular php framework widely used for web development. if you are trying to learn web development with laravel find how to Configure a Laravel application on local server(localhost).

What do we need to Configure a Laravel application on local server

  •  Local Server ( XAMPP , MAMP , LAMP )
  •  Code editor ( Sublime text , Visual Studio , as you chose)
  • PHP >= 7.1.3
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension
  • Ctype PHP Extension
  • JSON PHP Extension
  • BCMath PHP Extension

Laravel needs the Composer program to manage its extensions. If you do not have this program, you can download it from the site of Laravel or via the website getcomposer.org.

Once you successfully download downloading Composer.exe, run it, in the installation process, if you are prompted for the php.exe path, its address in your system is xampp/php by default.

If the composer is installed correctly, you’ll see the below picture by entering the composer command in cmd

Steps to Configure a Laravel application on local server

    • Create a database using localhost/PHPMyAdmin 
    • Once you create a local database, installed composer & git,
    • Create a directory on your local folder by Pulling Laravel/php project from git provider.  ( htdocs in xampp, and www in lamp and Wamp)
    • Rename .env.example file to .envinside your project root and fill the database information. (windows wont let you do it, so you have to open your console cd your project root directory and run mv .env.example .env )
    • Open the console and cd your project root directory
    • Since you already have installed composer and you are ready to run your first Laravel project

Follow the following command lines in the windows command prompt to run your laravel project after completing all the above steps.

( This will take you to the htdocs folder where your laravel project files are located)

C:\campp\htdocs\ (the folder where you pulled the laravel files in step 3 above)

After this run following command to execute your laravel project

  • Run composer install or php composer.phar install
  • Run php artisan key:generate
  • Run php artisan migrate
  • Run php artisan db:seed to run seeders, if any.
  • Run php artisan serve
  • After this run Localhost:8000 on your browser that will run your laravel project.

 

Brief about Laravel Architecture

Like all popular PHP frameworks such as Symfony, Yii, Codeigniter and others, Laravel is a MVC framework. Given this important point, it is important that you should understand the concept of MVC architecture. MVC stands for Model, View and Controller. It is an application architecture model which separates an application into three logical components:

    • Model: This component handles all the logic of the application
    • View: This component handles all the UI and presentation elements of the application
    • Controller: This component act as the interface between Model and View. This is where the business logic is processed.

Leave a Reply

Your email address will not be published. Required fields are marked *