app.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. require_once __DIR__ . '/../vendor/autoload.php';
  3. (new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(dirname(__DIR__)))->bootstrap();
  4. date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));
  5. /*
  6. * |--------------------------------------------------------------------------
  7. * | Create The Application
  8. * |--------------------------------------------------------------------------
  9. * |
  10. * | Here we will load the environment and create the application instance
  11. * | that serves as the central piece of this framework. We'll use this
  12. * | application as an "IoC" container and router for this framework.
  13. * |
  14. */
  15. $app = new Laravel\Lumen\Application(dirname(__DIR__));
  16. // $app->withFacades();
  17. $app->withEloquent();
  18. /*
  19. * |--------------------------------------------------------------------------
  20. * | Register Container Bindings
  21. * |--------------------------------------------------------------------------
  22. * |
  23. * | Now we will register a few bindings in the service container. We will
  24. * | register the exception handler and the console kernel. You may add
  25. * | your own bindings here if you like or you can make another file.
  26. * |
  27. */
  28. $app->singleton(Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class);
  29. $app->singleton(Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class);
  30. /*
  31. * |--------------------------------------------------------------------------
  32. * | Register Config Files
  33. * |--------------------------------------------------------------------------
  34. * |
  35. * | Now we will register the "app" configuration file. If the file exists in
  36. * | your configuration directory it will be loaded; otherwise, we'll load
  37. * | the default version. You may register other files below as needed.
  38. * |
  39. */
  40. if (env('APP_SWOOLE', false)) {
  41. $app->register(\SwooleTW\Http\LumenServiceProvider::class);
  42. $app->configure('swoole_http');
  43. }
  44. if (class_exists('Hhxsv5\LaravelS\Illuminate\LaravelSServiceProvider')) {
  45. $app->register(Hhxsv5\LaravelS\Illuminate\LaravelSServiceProvider::class);
  46. }
  47. $app->configure('database');
  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. // ]);
  64. /*
  65. * |--------------------------------------------------------------------------
  66. * | Register Service Providers
  67. * |--------------------------------------------------------------------------
  68. * |
  69. * | Here we will register all of the application's service providers which
  70. * | are used to bind services into the container. Service providers are
  71. * | totally optional, so you are not required to uncomment this line.
  72. * |
  73. */
  74. // $app->register(App\Providers\AppServiceProvider::class);
  75. // $app->register(App\Providers\AuthServiceProvider::class);
  76. // $app->register(App\Providers\EventServiceProvider::class);
  77. /*
  78. * |--------------------------------------------------------------------------
  79. * | Load The Application Routes
  80. * |--------------------------------------------------------------------------
  81. * |
  82. * | Next we will include the routes file so that they can all be added to
  83. * | the application. This will provide all of the URLs the application
  84. * | can respond to, as well as the controllers that may handle them.
  85. * |
  86. */
  87. $app->router->group([
  88. 'namespace' => 'App\Http\Controllers'
  89. ], function ($router) {
  90. require __DIR__ . '/../routes/web.php';
  91. });
  92. return $app;