Install Laravel and Basic Configurations

Published on Mar 21, 2019

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

Table of Contents

  1. Install Laravel
  2. Database Configuration
  3. Handle specified key was too long error
  4. Install Laravel UI
  5. Sample Blade File

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.3
  • BCMath PHP Extension
  • Ctype PHP Extension
  • Fileinfo 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

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.


Handle specified key was too long error

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

use Illuminate\Support\Facades\Schema;

public function boot()

Install Laravel UI

Laravel UI is an official package that contains the extracted UI parts from a Laravel project. To generate UI scaffolding, we first need to install the laravel/ui.

composer require laravel/ui

Once the laravel/ui package has been installed, you may install the frontend scaffolding using the ui Artisan command:

 * Generate basic scaffolding
 * Run one command only
php artisan ui bootstrap
php artisan ui vue
php artisan ui react

 * Generate login / registration scaffolding
 * Run one command if needed auth or skip this
php artisan ui bootstrap --auth
php artisan ui vue --auth
php artisan ui react --auth

Then run this command:

npm install && npm run dev
# migrate database
php artisan migrate

Sample Blade File

After generating UI, we need to inlcude CSS & JS in our blade file. Here’s an example:

<!DOCTYPE html>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hello from!</title>
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <div class="container">
        <div class="text-center" style="margin: 50px 0 10px 0;">
            Hello from!

    <script src="{{ asset('js/app.js') }}"></script>

We are done. Now continue with any Laravel project.