app.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. require_once __DIR__.'/../vendor/autoload.php';
  3. try {
  4. Dotenv\Dotenv::create(__DIR__.'/../')->load();
  5. } catch (Dotenv\Exception\InvalidPathException $e) {
  6. //
  7. }
  8. /*
  9. |--------------------------------------------------------------------------
  10. | Create The Application
  11. |--------------------------------------------------------------------------
  12. |
  13. | Here we will load the environment and create the application instance
  14. | that serves as the central piece of this framework. We'll use this
  15. | application as an "IoC" container and router for this framework.
  16. |
  17. */
  18. $app = new Laravel\Lumen\Application(
  19. realpath(__DIR__.'/../')
  20. );
  21. // $app->withFacades();
  22. $app->withEloquent();
  23. /*
  24. |--------------------------------------------------------------------------
  25. | Register Container Bindings
  26. |--------------------------------------------------------------------------
  27. |
  28. | Now we will register a few bindings in the service container. We will
  29. | register the exception handler and the console kernel. You may add
  30. | your own bindings here if you like or you can make another file.
  31. |
  32. */
  33. $app->singleton(
  34. Illuminate\Contracts\Debug\ExceptionHandler::class,
  35. App\Exceptions\Handler::class
  36. );
  37. $app->singleton(
  38. Illuminate\Contracts\Console\Kernel::class,
  39. App\Console\Kernel::class
  40. );
  41. /*
  42. |--------------------------------------------------------------------------
  43. | Register Middleware
  44. |--------------------------------------------------------------------------
  45. |
  46. | Next, we will register the middleware with the application. These can
  47. | be global middleware that run before and after each request into a
  48. | route or middleware that'll be assigned to some specific routes.
  49. |
  50. */
  51. // $app->middleware([
  52. // App\Http\Middleware\ExampleMiddleware::class
  53. // ]);
  54. // $app->routeMiddleware([
  55. // 'auth' => App\Http\Middleware\Authenticate::class,
  56. // ]);
  57. /*
  58. |--------------------------------------------------------------------------
  59. | Register Service Providers
  60. |--------------------------------------------------------------------------
  61. |
  62. | Here we will register all of the application's service providers which
  63. | are used to bind services into the container. Service providers are
  64. | totally optional, so you are not required to uncomment this line.
  65. |
  66. */
  67. // $app->register(App\Providers\AppServiceProvider::class);
  68. // $app->register(App\Providers\AuthServiceProvider::class);
  69. // $app->register(App\Providers\EventServiceProvider::class);
  70. if (env('APP_SWOOLE',false)) {
  71. $app->register(SwooleTW\Http\LumenServiceProvider::class);
  72. $app->configure('swoole_http');
  73. }
  74. /*
  75. |--------------------------------------------------------------------------
  76. | Load The Application Routes
  77. |--------------------------------------------------------------------------
  78. |
  79. | Next we will include the routes file so that they can all be added to
  80. | the application. This will provide all of the URLs the application
  81. | can respond to, as well as the controllers that may handle them.
  82. |
  83. */
  84. $app->router->group([
  85. 'namespace' => 'App\Http\Controllers',
  86. ], function ($router) {
  87. require __DIR__.'/../routes/web.php';
  88. });
  89. return $app;