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