five-say/laravel-api-tool

There is no license information available for the latest version (0.5.3) of this package.

self-use laravel api tool

0.5.3 2016-08-19 04:49 UTC

This package is not auto-updated.

Last update: 2024-02-29 00:41:27 UTC


README

自用 laravel api 辅助工具库

从 composer 安装

// 安装
composer require five-say/laravel-api-tool -vv
// 更新
composer update five-say/laravel-api-tool -vv

/api/config/app.php 中注册服务提供者

<?php

    'providers' => [
        ...
        FiveSay\Laravel\Api\ServiceProvider::class,
    ],

执行 artisan 命令,发布扩展文件

php artisan vendor:publish --provider="FiveSay\Laravel\Api\ServiceProvider"

/api/bootstrap/autoload.php 中引入核心函数库

<?php

define('LARAVEL_START', microtime(true));

// 核心函数定义,最高优先级
require __DIR__.'/../ext/changeCoreHelpers.php';

/api/app/Http/Kernel.php 中添加路由中间件

<?php

    protected $routeMiddleware = [
        ...
        'module'   => \FiveSay\Laravel\Api\Middleware\ModuleMiddleware::class,
        'jwt.auth' => \FiveSay\Laravel\Api\Middleware\JwtAuthMiddleware::class,
        'jwt.both' => \FiveSay\Laravel\Api\Middleware\JwtBothMiddleware::class,
        'api.auth' => \Ext\Middleware\ApiAuthMiddleware::class,

    ];

修改 /api/app/Providers/RouteServiceProvider.php 中的全局路由中间件设置

<?php

    protected function mapWebRoutes(Router $router)
    {
        $router->group([
            // 'namespace' => $this->namespace, 'middleware' => 'web',
            'namespace' => $this->namespace, 'middleware' => 'api',
        ], function ($router) {
            require app_path('Http/routes.php');
        });
    }