app.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Create The Application
  5. |--------------------------------------------------------------------------
  6. |
  7. | The first thing we will do is create a new Laravel application instance
  8. | which serves as the "glue" for all the components of Laravel, and is
  9. | the IoC container for the system binding all of the various parts.
  10. |
  11. */
  12. if (! function_exists('envUnlessEmpty')) {
  13. /**
  14. * @return mixed|null
  15. */
  16. function envUnlessEmpty(string $key, string|int|bool|float|array|null $default = null)
  17. {
  18. $result = env($key, $default);
  19. if ('' === $result) {
  20. $result = $default;
  21. }
  22. return $result;
  23. }
  24. }
  25. $app = new Illuminate\Foundation\Application(
  26. $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
  27. );
  28. /*
  29. |--------------------------------------------------------------------------
  30. | Bind Important Interfaces
  31. |--------------------------------------------------------------------------
  32. |
  33. | Next, we need to bind some important interfaces into the container so
  34. | we will be able to resolve them when needed. The kernels serve the
  35. | incoming requests to this application from both the web and CLI.
  36. |
  37. */
  38. $app->singleton(
  39. Illuminate\Contracts\Http\Kernel::class,
  40. App\Http\Kernel::class
  41. );
  42. $app->singleton(
  43. Illuminate\Contracts\Console\Kernel::class,
  44. App\Console\Kernel::class
  45. );
  46. $app->singleton(
  47. Illuminate\Contracts\Debug\ExceptionHandler::class,
  48. App\Exceptions\Handler::class
  49. );
  50. /*
  51. |--------------------------------------------------------------------------
  52. | Return The Application
  53. |--------------------------------------------------------------------------
  54. |
  55. | This script returns the application instance. The instance is given to
  56. | the calling script so we can separate the building of the instances
  57. | from the actual running of the application and sending responses.
  58. |
  59. */
  60. return $app;