Skip to content
/ l9api Public

The project was built on Laravel 9 (for API multiauth)

Notifications You must be signed in to change notification settings

tienhm7/l9api

Repository files navigation

Build Status Total Downloads Latest Stable Version License

Install Laravel API

  • Copy .env.example to .env
  • Edit APP_URL with API URL, edit MySQL config.
  • Run command
    composer install
    php artisan migrate --seed
    php artisan passport:install
    

Use multi auth

  • Step 1: Add guards and providers to config/auth.php
  • Step 2: Model use trait Laravel\Passport\HasApiTokens
  • Step 3: Specify user provider uses --provider option

Example: provider customers

php artisan passport:client --password --provider=customers

Common

1. Constant

Instead of using const in class to import. We will use const in config/constants.php Example:

    'TYPE_CUSTOMER' => 'customer',
    'TYPE_ADMIN' => 'admin',
    'TYPE_MANAGER' => 'manager',

2. Rule commit

Rule Commit Message

Based on the Angular convention:

type(scope?): subject
  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to our CI configuration files and scripts (example scopes: Gitlab CI, Circle, BrowserStack, SauceLabs)
  • chore: add something without touching production code (Eg: update npm dependencies)
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Reverts a previous commit
  • style: Changes that do not affect the meaning of the code (Eg: adding white-space, formatting, missing semi-colons, etc)
  • test: Adding missing tests or correcting existing tests

Package Intergrate

Laravel Debugbar

https://github.com/barryvdh/laravel-debugbar

Laravel IDE Helper Generator

https://github.com/barryvdh/laravel-ide-helper

Passport (use Password Grant Tokens):

https://laravel.com/docs/8.x/passport

Laravel Permission:

https://spatie.be/docs/laravel-permission/v5/basic-usage/basic-usage

Generate doc api (Swagger):

https://github.com/DarkaOnLine/L5-Swagger

  1. Add comments to controller's method

/**
     * @OA\Post(
     *  path="/auth/login",
     *  operationId="registerUser",
     *  tags={"User"},
     *  summary="Register user",
     *  description="Returns message and status",
     *  @OA\Parameter(name="name",
     *    in="query",
     *    required=true,
     *    @OA\Schema(type="string")
     *  ),
     *  @OA\Parameter(name="email",
     *    in="query",
     *    required=true,
     *    @OA\Schema(type="string")
     *  ),
     *  @OA\Parameter(name="password",
     *    in="query",
     *    required=true,
     *    @OA\Schema(type="string")
     *  ),
     *  @OA\Response(response="201",
     *    description="Register success",
     *  )
     * )
     */

Reference: https://blog.quickadminpanel.com/laravel-api-documentation-with-openapiswagger/

  1. Run
   php artisan l5-swagger:generate
   sudo chmod 777 -R storage/api-docs/
  1. View document api You can access your documentation at /api/documentation endpoint

Laravel Excel

Read More: https://docs.laravel-excel.com/3.1/getting-started/

About

The project was built on Laravel 9 (for API multiauth)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages