Md. Obydullah Howdy, I am Md. Obydullah from Bangladesh. I love to write the article which will help others. It's my passion.

Install Laravel 5.8 and Basic Configurations

Last modified on April 11, 2019 42 sec read

In this tutorial, I’m going to install Laravel and do the basic configuration which needs in any Laravel project.

Table of Contents

  1. Install Laravel
  2. Database Configuration
  3. Handle specified key was too long error

Step 1 : Install Laravel

Let’s install a fresh Laravel project. Before installation you will need to make sure your server meets the following requirements:

  • 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

Go to your project folder (for xampp, go to htdocs folder) and write this command in your terminal to create a project.

composer create-project --prefer-dist laravel/laravel laravelproject

Step 2 : Database Configuration

In the Laravel project, there is a file called .env. It’s for project configuration. To connect with the database we need to set database credentials.

.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password

Step 3 : Handle specified key was too long error

To handle this error, go to this file app/Providers/AppServiceProvider.php and inside the bootmethod set a default string length:

AppServiceProvider.php
use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

We are done. Now continue with any Laravel project.

Md. Obydullah Howdy, I am Md. Obydullah from Bangladesh. I love to write the article which will help others. It's my passion.

Leave a Reply

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