Laravel: Getting Start

Table of Contents

Laravel MVC framework

Laravel is a free, open-source PHP MVC framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller architectural pattern and based on Symfony

Build simple to advanced web applications using PHP’s most popular web framework.

Why Laravel?

  1. Secure authorization and authentication systems
  2. Completely customizable
  3. Integration with mail services.
  4. Clean documentation and Model View Controller (MVC) support
  5. Fast development time
  6. Expandable requirements for future
  7. Cost-effective

How to Install?

Useful resources for download and installation:

  1. How to Install and Use Composer
  2. Documentation

Laravel MVC framework : Artisan commands

Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. It is driven by the powerful Symfony Console component.

php artisan serve
php artisan serve --port 8080

Laravel MVC framework: Introduction to views

Laravel is the MVC (Model View Controller) framework. The view part deals with presenting the data to the user. This is usually in form of HTML pages.
Q: Where are views stored in a laravel project?
A: The resources/views folder


The most basic Laravel routes accept a URI and a Closure, providing a very simple and expressive method of defining routes:

Route::get('/', function () {
    return view('welcome');
Route::get('about', 'AboutController@index');

Introducing controllers

MVC Controllers are responsible for controlling the flow of the application execution. Controllers are simple PHP classes in the MVC framework. We will create a controller using the artisan command in Laravel:

php artisan make:controller AboutController

Introducing migrations and models

The model represents domain-specific data and business logic in MVC architecture. It maintains the data of the application. Model objects retrieve and store model states in the persistence store like a database.

php artisan make:model About

Database connection in Laravel

Migrations are like version control for your database, allowing your team to easily modify and share the application’s database schema. Migrations are typically paired with Laravel’s schema builder to easily build your application’s database schema. If you have ever had to tell a teammate to manually add a column to their local database schema, you’ve faced the problem that database migrations solve.

php artisan make:migration create_about_table
php artisan migrate

Laravel Migration Error Solution:
According to the official documentation, you can solve this quite easily.

According to the official documentation, you can solve this quite easily.

Add following code to AppServiceProvider.php (/app/Providers/AppServiceProvider.php)

use Illuminate\Support\Facades\Schema; //NEW: Import Schema
function boot()
        Schema::defaultStringLength(191); //NEW: Increase StringLength
php artisan migrate:rollback

rollback command will execute down function in migration table

   public function down()
php artisan migrate:refresh