app.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. require_once __DIR__ . '/../vendor/autoload.php';
  3. (new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
  4. dirname(__DIR__)
  5. ))->bootstrap();
  6. /*
  7. |--------------------------------------------------------------------------
  8. | Create The Application
  9. |--------------------------------------------------------------------------
  10. |
  11. | Here we will load the environment and create the application instance
  12. | that serves as the central piece of this framework. We'll use this
  13. | application as an "IoC" container and router for this framework.
  14. |
  15. */
  16. $app = new Laravel\Lumen\Application(
  17. dirname(__DIR__)
  18. );
  19. $app->withFacades();
  20. //加载配置文件
  21. $app->configure('cors');
  22. $app->configure('api');
  23. $app->configure('auth');
  24. $app->configure('wechat');
  25. $app->configure('sms');
  26. $app->configure('filesystems');
  27. $app->configure('database');
  28. $app->configure('queue');
  29. $app->configure('bike');
  30. /*
  31. |--------------------------------------------------------------------------
  32. | Register Container Bindings
  33. |--------------------------------------------------------------------------
  34. |
  35. | Now we will register a few bindings in the service container. We will
  36. | register the exception handler and the console kernel. You may add
  37. | your own bindings here if you like or you can make another file.
  38. |
  39. */
  40. $app->singleton(
  41. Illuminate\Contracts\Debug\ExceptionHandler::class,
  42. App\Exceptions\Handler::class
  43. );
  44. $app->singleton(
  45. Illuminate\Contracts\Console\Kernel::class,
  46. App\Console\Kernel::class
  47. );
  48. /*
  49. |--------------------------------------------------------------------------
  50. | Register Middleware
  51. |--------------------------------------------------------------------------
  52. |
  53. | Next, we will register the middleware with the application. These can
  54. | be global middleware that run before and after each request into a
  55. | route or middleware that'll be assigned to some specific routes.
  56. |
  57. */
  58. // $app->middleware([
  59. // App\Http\Middleware\ExampleMiddleware::class
  60. // ]);
  61. $app->routeMiddleware([
  62. 'auth' => App\Http\Middleware\Authenticate::class,
  63. 'serializer' => \Liyu\Dingo\SerializerSwitch::class,
  64. 'cors' => \Barryvdh\Cors\HandleCors::class,
  65. 'jwt.role' => \App\Http\Middleware\JWTRoleAuth::class,
  66. 'singleLogin' => \App\Http\Middleware\SingleLoginLimit::class,
  67. ]);
  68. /*
  69. |--------------------------------------------------------------------------
  70. | Register Service Providers
  71. |--------------------------------------------------------------------------
  72. |
  73. | Here we will register all of the application's service providers which
  74. | are used to bind services into the container. Service providers are
  75. | totally optional, so you are not required to uncomment this line.
  76. |
  77. */
  78. $app->register(App\Providers\AppServiceProvider::class);
  79. $app->register(App\Providers\AuthServiceProvider::class);
  80. $app->register(App\Providers\EventServiceProvider::class);
  81. $app->register(\Tymon\JWTAuth\Providers\LumenServiceProvider::class);
  82. $app->register(Dingo\Api\Provider\LumenServiceProvider::class);
  83. $app->register(Barryvdh\Cors\ServiceProvider::class);
  84. $app->register(Overtrue\LaravelWeChat\ServiceProvider::class);
  85. $app->register(Illuminate\Redis\RedisServiceProvider::class);
  86. $app->register(Overtrue\LaravelLang\TranslationServiceProvider::class);
  87. $app->register(Jenssegers\Mongodb\MongodbServiceProvider::class);
  88. $app->register(Overtrue\LaravelFilesystem\Qiniu\QiniuStorageServiceProvider::class);
  89. $app->withEloquent();
  90. /*
  91. |--------------------------------------------------------------------------
  92. | Load The Application Routes
  93. |--------------------------------------------------------------------------
  94. |
  95. | Next we will include the routes file so that they can all be added to
  96. | the application. This will provide all of the URLs the application
  97. | can respond to, as well as the controllers that may handle them.
  98. |
  99. */
  100. $app->router->group([
  101. 'namespace' => 'App\Http\Controllers',
  102. ], function ($router) {
  103. require __DIR__ . '/../routes/api-v1.php';
  104. });
  105. return $app;