img

Laravel 5 Installation & Configuration

In this article, we will cover Laravel 5.6 installation & configuration of database and server.we will work with windows machine but still, you can follow same command & instruction with other operating systems.

TABLE OF CONTENT

We will cover the following topics.

  • Pre-requirements for install Laravel.
  • Laravel Installation using composer.
  • Configure Laravel project.

Pre-requirements for install Laravel

Before proceeding to install laravel, you have the following programmes need to install.

    1. Web Server
    2. PHP (>= 7.1.3)
    3. MySQL
  1. Composer
  2. Integrated Development Environment (IDE)

Web server, PHP & MySQL

For installation of this, we will use XAMPP, XAMPP comes with Apache server, PHP & MySQL.If you don’t have XAMPP you can download from this link. if you prefer any other web server you can go with it, but i would prefer to use XAMPP for Laravel.

Composer

Composer is the dependency package manager for PHP. You can read more about the composer from their official website. you can download the composer from the same link. you can get the instruction how to install from the website.

Integrated Development Environment (IDE)

Will need IDE for write PHP code, this is an optional step but highly recommended. You can use any lightweight text editor like Notepad++, Sublime Text 3 and Visual Studio Code. You can also go with PHPStrom or NetBeans which come along with comprehensive feature set including tools and integrations.

Install Laravel using Composer

Step 1: Navigate to web server root

  1. Assume you install xampp to C:/xampp/, now open windows explorer and navigate to C:/xampp/htdocs.
  2. Now Right click anywhere in C:/xampp/htdocs and select “Use Composer here” , you will get below command prompt window

Composer Install CMD

Step 2: Install Laravel project using composer

Run below command

composer create-project laravel/laravel laravel-demo

after run command, you will get following output in windows command prompt,

Now, wait for a moment to complete the installation.

Laravel Installation Snap

Step 3: Test Project installation

Now you can browse below URL to get access to the website.

http://localhost/laravel-demo/public/

You can use Artisan command to run the project.

php artisan serve

once you fire this command project run on 8000 port and you can access project by below url.

http://localhost:8000

Configure Laravel Project

The configuration you can set from  /config/app.php.

  1. set debugging mode: it is helpful to configure when to display error/notice/warnings.
  2. setup environment: it is helpful to configure different environments like dev/uat/prod.
  3. set the time zone: it helps to set up time zone for your project.
  4. set the maintenance mode: it helps when do you want to enable & disable maintenance message to your app user.

Debugging mode

to enable debugging mode

'debug' => env('APP_DEBUG', true),

to disable debugging mode

'debug' => env('APP_DEBUG', false),

Environments

You can set different environments like local/dev/uat/production.

'env' => env('APP_ENV', 'production'),

Time zone

'timezone' => 'UTC',

Maintenance Mode

To enable maintenance mode, execute down command.

php artisan down

To disable maintenance mode, execute up command.

php artisan up

Database Configuration

The database configuration file is located in /config/database.php. In Laravel MySQL is default database engine.you can also choose different database engine as per your need, but in this article i am going to show you for MySQL.

Below key fields we need to update:

  • host
  • database
  • username
  • password

Locate the following lines.

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'forge'),
    'username' => env('DB_USERNAME', 'forge'),
    'password' => env('DB_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'strict' => true,
    'engine' => null,
],

Update above code with correct values.

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', 'localhsot'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'larave-demo'),
    'username' => env('DB_USERNAME', 'root'),
    'password' => env('DB_PASSWORD', 'password'),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'strict' => true,
    'engine' => null,
],

SUMMARY

In this article we learn about:

  • The pre-requirements of Laravel installation. PHP, MySQL, composer and for writing code IDE.
  • How to configure Laravel project.

 

  • Facebook
  • Twitter
  • Google+
  • Linkedin
  • Pinterest

Leave a Comment

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

It is main inner container footer text