Laravel

Laravel

About Laravel

  • Laravel is PHP based modern and most used framework.
  • Very easy to develop web application and API
  • Open source
  • Click for official site.

Why use Laravel

  • Fast and Easy to develop
  • Strong command line support
  • Regular update
  • Large Community
  • Easy to develop API

Prerequisites

Install xamp for PHP and MySql

composer

Laravel Installation

Now open cmd terminal and run the below code to create laravel project name “products” composer create-project --prefer-dist laravel/laravel prducts

Routing

Controller

View

Model

Middleware

Laravel Package

Passport

1. Installation Passport

composer require laravel/passport

If timeout error shows then run the below command

COMPOSER_MEMORY_LIMIT=-1 composer require laravel/passport

2. Migration

php artisan migrate

3. Key Generate

php artisan passport:install

4. User Model

use Laravel\Passport\HasApiTokens;
use JasApiTokens, HasFactory, Notifiable;

5. Update Api\Providers\AuthServiceProvider

use Laravel\Passport\Passport;

In boot function add the below code

Passport::routes();

6. Update config/auth.php

 'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],

7. create route and function in the controller

Important Laravel commands

Laravel commands

 

Important Laravel Command