Md Obydullah Follow I'm Md Obydullah. I build open-source projects and write about Laravel, Linux server, modern JavaScript and web development.

Install Laravel and Basic Configurations

Last modified on November 1, 2019 44 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.2.0
  • BCMath PHP Extension
  • Ctype PHP Extension
  • JSON PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

Method 1: You can install Laravel using Laravel installer:

 # install installer
composer global require laravel/installer
# create project
laravel new my_porject

Method 2: You can also install Laravel using composer:

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

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.

You're welcome to suggest any article to write!

Md Obydullah Follow I'm Md Obydullah. I build open-source projects and write about Laravel, Linux server, modern JavaScript and web development.

Leave a Reply

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