|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| -/* |
4 |
| -|-------------------------------------------------------------------------- |
5 |
| -| Create The Application |
6 |
| -|-------------------------------------------------------------------------- |
7 |
| -| |
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 |
10 |
| -| the IoC container for the system binding all of the various parts. |
11 |
| -| |
12 |
| -*/ |
13 |
| - |
14 |
| -$app = new Illuminate\Foundation\Application( |
15 |
| - realpath(__DIR__ . '/../') |
16 |
| -); |
17 |
| - |
18 |
| -/* |
19 |
| -|-------------------------------------------------------------------------- |
20 |
| -| Bind Important Interfaces |
21 |
| -|-------------------------------------------------------------------------- |
22 |
| -| |
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 |
25 |
| -| incoming requests to this application from both the web and CLI. |
26 |
| -| |
27 |
| -*/ |
28 |
| - |
29 |
| -$app->singleton( |
30 |
| - Illuminate\Contracts\Http\Kernel::class, |
31 |
| - App\Http\Kernel::class |
32 |
| -); |
33 |
| - |
34 |
| -$app->singleton( |
35 |
| - Illuminate\Contracts\Console\Kernel::class, |
36 |
| - App\Console\Kernel::class |
37 |
| -); |
38 |
| - |
39 |
| -$app->singleton( |
40 |
| - Illuminate\Contracts\Debug\ExceptionHandler::class, |
41 |
| - App\Exceptions\Handler::class |
42 |
| -); |
43 |
| - |
44 |
| -/* |
45 |
| -|-------------------------------------------------------------------------- |
46 |
| -| Return The Application |
47 |
| -|-------------------------------------------------------------------------- |
48 |
| -| |
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 |
51 |
| -| from the actual running of the application and sending responses. |
52 |
| -| |
53 |
| -*/ |
54 |
| - |
55 |
| -return $app; |
| 3 | +use Illuminate\Foundation\Application; |
| 4 | +use Illuminate\Foundation\Configuration\Exceptions; |
| 5 | +use Illuminate\Foundation\Configuration\Middleware; |
| 6 | + |
| 7 | +return Application::configure(basePath: dirname(__DIR__)) |
| 8 | + ->withRouting( |
| 9 | + web: __DIR__ . '/../routes/web.php', |
| 10 | + commands: __DIR__ . '/../routes/console.php', |
| 11 | + health: '/up', |
| 12 | + ) |
| 13 | + ->withMiddleware(function (Middleware $middleware) { |
| 14 | + $middleware->use([ |
| 15 | + // \App\Http\Middleware\TrustHosts::class, |
| 16 | + \App\Http\Middleware\TrustProxies::class, |
| 17 | + \Illuminate\Http\Middleware\HandleCors::class, |
| 18 | + \App\Http\Middleware\PreventRequestsDuringMaintenance::class, |
| 19 | + \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, |
| 20 | + \App\Http\Middleware\TrimStrings::class, |
| 21 | + \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, |
| 22 | + ]); |
| 23 | + |
| 24 | + $middleware->group('web', [ |
| 25 | + \App\Http\Middleware\EncryptCookies::class, |
| 26 | + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
| 27 | + \Illuminate\Session\Middleware\StartSession::class, |
| 28 | + \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
| 29 | + \App\Http\Middleware\VerifyCsrfToken::class, |
| 30 | + \Illuminate\Routing\Middleware\SubstituteBindings::class, |
| 31 | + ]); |
| 32 | + |
| 33 | + $middleware->group('api', [ |
| 34 | + // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, |
| 35 | + \Illuminate\Routing\Middleware\ThrottleRequests::class . ':api', |
| 36 | + \Illuminate\Routing\Middleware\SubstituteBindings::class, |
| 37 | + ]); |
| 38 | + |
| 39 | + $middleware->alias([ |
| 40 | + 'auth' => \App\Http\Middleware\Authenticate::class, |
| 41 | + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
| 42 | + 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, |
| 43 | + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, |
| 44 | + 'can' => \Illuminate\Auth\Middleware\Authorize::class, |
| 45 | + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, |
| 46 | + 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, |
| 47 | + 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, |
| 48 | + 'signed' => \App\Http\Middleware\ValidateSignature::class, |
| 49 | + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
| 50 | + 'role' => \App\Http\Middleware\RoleMiddleware::class, |
| 51 | + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, |
| 52 | + ]); |
| 53 | + }) |
| 54 | + ->withExceptions(function (Exceptions $exceptions) { |
| 55 | + // |
| 56 | + })->create(); |
0 commit comments