作者 pengjch

dev: composer test1

  1 +<?php
  2 +namespace AukeySwrpc\Http;
  3 +
  4 +use Illuminate\Support\Facades\Route;
  5 +use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
  6 +
  7 +class RouteServiceProvider extends ServiceProvider{
  8 + public function boot(){
  9 + parent::boot();
  10 + }
  11 +
  12 + public function map(){
  13 + $this->mapWebRoutes();
  14 +
  15 + $this->mapApiRoutes();
  16 + }
  17 +
  18 + /**
  19 + * web路由设置
  20 + */
  21 + protected function mapWebRoutes(){
  22 + Route::middleware('web')
  23 + ->namespace('Swrpc\Http\Controllers')
  24 + ->group(__DIR__ . '/Controllers/routes.php');
  25 + }
  26 +
  27 + /**
  28 + * api路由设置
  29 + */
  30 + protected function mapApiRoutes(){
  31 + Route::prefix('api')
  32 + ->middleware('api')
  33 + ->namespace('Swrpc\Http\Controllers')
  34 + ->group(__DIR__ . '/Controllers/routes.php');
  35 + }
  36 +}
  1 +<?php
  2 +
  3 +namespace AukeySwrpc;
  4 +
  5 +use Illuminate\Support\ServiceProvider;
  6 +
  7 +class SwrpcProvider extends ServiceProvider
  8 +{
  9 + public function boot()
  10 + {
  11 + $this->loadMigrationsFrom(__DIR__ . '/database/migrations');
  12 + if ($this->app->runningInConsole()) {
  13 + $this->commands([
  14 + ]);
  15 + }
  16 + }
  17 +
  18 + public function register()
  19 + {
  20 + $provides = [
  21 + 'AukeySwrpc\Http\RouteServiceProvider',
  22 + ];
  23 + foreach ($provides as $provider) {
  24 + $this->app->register($provider);
  25 + }
  26 + }
  27 +}