Install Laravel and Basic Configurations
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
- Install Laravel
- Database Configuration
- Handle specified key was too long error
- Install Laravel UI
- 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.
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
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()
{
Schema::defaultStringLength(191);
}
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>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello from Shouts.dev!</title>
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="text-center" style="margin: 50px 0 10px 0;">
Hello from Shouts.dev!
</div>
</div>
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>
We are done. Now continue with any Laravel project.
Comment
Preview may take a few seconds to load.
Markdown Basics
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Italics *asterisks*
Bold **double asterisks**
Code
Inline Code
`backtick`Code Block```
Three back ticks and then enter your code blocks here.
```
Headers
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
Quotes
> type a greater than sign and start typing your quote.
Links
You can add links by adding text inside of [] and the link inside of (), like so:
Lists
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
Images
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of [], and the image URL inside of (), like so:
Dividers
To add a divider you can add three dashes or three asterisks:
--- or ***

Comments (0)