app.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. require_once __DIR__.'/../vendor/autoload.php';
  3. try {
  4. (new Dotenv\Dotenv(__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->configure('errcode');
  22. $app->configure('errmsg');
  23. $app->withFacades();
  24. $app->withEloquent();
  25. /*
  26. |--------------------------------------------------------------------------
  27. | Register Container Bindings
  28. |--------------------------------------------------------------------------
  29. |
  30. | Now we will register a few bindings in the service container. We will
  31. | register the exception handler and the console kernel. You may add
  32. | your own bindings here if you like or you can make another file.
  33. |
  34. */
  35. $app->singleton(
  36. Illuminate\Contracts\Debug\ExceptionHandler::class,
  37. App\Exceptions\Handler::class
  38. );
  39. $app->singleton(
  40. Illuminate\Contracts\Console\Kernel::class,
  41. App\Console\Kernel::class
  42. );
  43. $app->singleton('redisLog',function (){
  44. $redis = new \Redis();
  45. $redis->connect(env("REDIS_HOST_LOG"), env("REDIS_PORT_LOG"));
  46. if(!empty(env("REDIS_PASSWORD_LOG"))) $redis->auth(env("REDIS_PASSWORD_LOG"));
  47. return $redis;
  48. });
  49. /*
  50. |--------------------------------------------------------------------------
  51. | Register Middleware
  52. |--------------------------------------------------------------------------
  53. |
  54. | Next, we will register the middleware with the application. These can
  55. | be global middleware that run before and after each request into a
  56. | route or middleware that'll be assigned to some specific routes.
  57. |
  58. */
  59. $app->middleware([
  60. ]);
  61. $app->routeMiddleware([
  62. ]);
  63. // $app->routeMiddleware([
  64. // 'auth' => App\Http\Middleware\Authenticate::class,
  65. // ]);
  66. /*
  67. |--------------------------------------------------------------------------
  68. | Register Service Providers
  69. |--------------------------------------------------------------------------
  70. |
  71. | Here we will register all of the application's service providers which
  72. | are used to bind services into the container. Service providers are
  73. | totally optional, so you are not required to uncomment this line.
  74. |
  75. */
  76. // $app->register(App\Providers\AppServiceProvider::class);
  77. // $app->register(App\Providers\AuthServiceProvider::class);
  78. // $app->register(App\Providers\EventServiceProvider::class);
  79. $app->register(Illuminate\Redis\RedisServiceProvider::class);
  80. /*
  81. |--------------------------------------------------------------------------
  82. | Load The Application Routes
  83. |--------------------------------------------------------------------------
  84. |
  85. | Next we will include the routes file so that they can all be added to
  86. | the application. This will provide all of the URLs the application
  87. | can respond to, as well as the controllers that may handle them.
  88. |
  89. */
  90. $app->router->group([
  91. 'namespace' => 'App\Http\Controllers',
  92. ], function ($router) {
  93. require __DIR__.'/../routes/web.php';
  94. });
  95. return $app;