app.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. $app->withEloquent();
  21. $app->configure('api');
  22. $app->configure('apollo');
  23. $app->configure('auth');
  24. $app->configure('jwt');
  25. $app->configure('customer');
  26. $app->configure('database');
  27. $app->configure('constants');
  28. $app->configure('aliyunvod');
  29. $app->configure('cors');
  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->middleware([
  62. App\Http\Middleware\SqlMiddleware::class,
  63. \Barryvdh\Cors\HandleCors::class
  64. ]);
  65. $app->routeMiddleware([
  66. 'auth' => App\Http\Middleware\Authenticate::class,
  67. 'jwt.chxq_auth' => App\Http\Middleware\JwtAuthMiddleware::class,
  68. 'cors' => \Barryvdh\Cors\HandleCors::class
  69. ]);
  70. /*
  71. |--------------------------------------------------------------------------
  72. | Register Service Providers
  73. |--------------------------------------------------------------------------
  74. |
  75. | Here we will register all of the application's service providers which
  76. | are used to bind services into the container. Service providers are
  77. | totally optional, so you are not required to uncomment this line.
  78. |
  79. */
  80. $app->register(App\Providers\AppServiceProvider::class);
  81. $app->register(App\Providers\AuthServiceProvider::class);
  82. $app->register(Dingo\Api\Provider\LumenServiceProvider::class);
  83. $app->register(Tymon\JWTAuth\Providers\LumenServiceProvider::class);
  84. $app->register(\Illuminate\Redis\RedisServiceProvider::class);
  85. $app->register(\Junliuxian\AliOSS\AliOssServiceProvider::class);
  86. $app->register(\ZanySoft\Zip\ZipServiceProvider::class);
  87. $app->register(\SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class);
  88. $app->register(\Barryvdh\Cors\ServiceProvider::class);
  89. $app->register(\Intervention\Image\ImageServiceProvider::class);
  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.php';
  104. require __DIR__ . '/../routes/web.php';
  105. });
  106. return $app;