You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.8 KiB

  1. <?php
  2. /*
  3. * app.php
  4. * Copyright (c) 2021 james@firefly-iii.org
  5. *
  6. * This file is part of the Firefly III Data Importer
  7. * (https://github.com/firefly-iii/data-importer).
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. declare(strict_types=1);
  23. bcscale(12);
  24. if (!function_exists('envNonEmpty')) {
  25. /**
  26. * @param string $key
  27. * @param null $default
  28. *
  29. * @return mixed|null
  30. */
  31. function envNonEmpty(string $key, $default = null)
  32. {
  33. $result = env($key, $default);
  34. if (is_string($result) && '' === $result) {
  35. $result = $default;
  36. }
  37. return $result;
  38. }
  39. }
  40. /*
  41. |--------------------------------------------------------------------------
  42. | Create The Application
  43. |--------------------------------------------------------------------------
  44. |
  45. | The first thing we will do is create a new Laravel application instance
  46. | which serves as the "glue" for all the components of Laravel, and is
  47. | the IoC container for the system binding all of the various parts.
  48. |
  49. */
  50. $app = new Illuminate\Foundation\Application(
  51. $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
  52. );
  53. /*
  54. |--------------------------------------------------------------------------
  55. | Bind Important Interfaces
  56. |--------------------------------------------------------------------------
  57. |
  58. | Next, we need to bind some important interfaces into the container so
  59. | we will be able to resolve them when needed. The kernels serve the
  60. | incoming requests to this application from both the web and CLI.
  61. |
  62. */
  63. $app->singleton(
  64. Illuminate\Contracts\Http\Kernel::class,
  65. App\Http\Kernel::class
  66. );
  67. $app->singleton(
  68. Illuminate\Contracts\Console\Kernel::class,
  69. App\Console\Kernel::class
  70. );
  71. $app->singleton(
  72. Illuminate\Contracts\Debug\ExceptionHandler::class,
  73. App\Exceptions\Handler::class
  74. );
  75. /*
  76. |--------------------------------------------------------------------------
  77. | Return The Application
  78. |--------------------------------------------------------------------------
  79. |
  80. | This script returns the application instance. The instance is given to
  81. | the calling script so we can separate the building of the instances
  82. | from the actual running of the application and sending responses.
  83. |
  84. */
  85. return $app;