|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App\Application\Bootloader; |
|
6
|
|
|
|
|
7
|
|
|
use GraphQL\Upload\UploadMiddleware; |
|
|
|
|
|
|
8
|
|
|
use Spiral\Bootloader\Http\RoutesBootloader as BaseRoutesBootloader; |
|
|
|
|
|
|
9
|
|
|
use Spiral\Cookies\Middleware\CookiesMiddleware; |
|
|
|
|
|
|
10
|
|
|
use Spiral\Csrf\Middleware\CsrfMiddleware; |
|
|
|
|
|
|
11
|
|
|
use Spiral\Debug\StateCollector\HttpCollector; |
|
|
|
|
|
|
12
|
|
|
use Spiral\Http\Middleware\ErrorHandlerMiddleware; |
|
|
|
|
|
|
13
|
|
|
use Spiral\Http\Middleware\JsonPayloadMiddleware; |
|
|
|
|
|
|
14
|
|
|
use Spiral\Router\Bootloader\AnnotatedRoutesBootloader; |
|
|
|
|
|
|
15
|
|
|
use Spiral\Router\Loader\Configurator\RoutingConfigurator; |
|
|
|
|
|
|
16
|
|
|
use Spiral\Session\Middleware\SessionMiddleware; |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* A bootloader that configures the application's routes and middleware. |
|
20
|
|
|
* |
|
21
|
|
|
* @link https://spiral.dev/docs/http-routing |
|
22
|
|
|
*/ |
|
23
|
|
|
final class RoutesBootloader extends BaseRoutesBootloader |
|
24
|
|
|
{ |
|
25
|
|
|
protected const DEPENDENCIES = [ |
|
26
|
|
|
AnnotatedRoutesBootloader::class, |
|
27
|
|
|
]; |
|
28
|
|
|
|
|
29
|
|
|
protected function globalMiddleware(): array |
|
30
|
|
|
{ |
|
31
|
|
|
return [ |
|
32
|
|
|
// If you want to automatically detect the user's locale based on the |
|
33
|
|
|
// "Accept-Language" header uncomment this middleware and add \Spiral\Bootloader\I18nBootloader |
|
34
|
|
|
// to the Kernel |
|
35
|
|
|
// LocaleSelector::class, |
|
36
|
|
|
|
|
37
|
|
|
ErrorHandlerMiddleware::class, |
|
38
|
|
|
JsonPayloadMiddleware::class, |
|
39
|
|
|
UploadMiddleware::class, |
|
40
|
|
|
HttpCollector::class, |
|
41
|
|
|
]; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
protected function middlewareGroups(): array |
|
45
|
|
|
{ |
|
46
|
|
|
return [ |
|
47
|
|
|
'web' => [ |
|
48
|
|
|
CookiesMiddleware::class, |
|
49
|
|
|
SessionMiddleware::class, |
|
50
|
|
|
CsrfMiddleware::class, |
|
51
|
|
|
// Uncomment this middleware if you want to authenticate users using cookies |
|
52
|
|
|
// new Autowire(AuthTransportMiddleware::class, ['transportName' => 'cookie']) |
|
53
|
|
|
], |
|
54
|
|
|
'api' => [ |
|
55
|
|
|
// Uncomment this middleware if you want to authenticate users using headers |
|
56
|
|
|
// new Autowire(AuthTransportMiddleware::class, ['transportName' => 'header']) |
|
57
|
|
|
], |
|
58
|
|
|
]; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
protected function defineRoutes(RoutingConfigurator $routes): void |
|
62
|
|
|
{ |
|
63
|
|
|
// Fallback route if no other route matched |
|
64
|
|
|
// Will show 404 page |
|
65
|
|
|
// $routes->default('/<path:.*>') |
|
66
|
|
|
// ->callable(function (ServerRequestInterface $r, ResponseInterface $response) { |
|
67
|
|
|
// return $response->withStatus(404)->withBody('Not found'); |
|
68
|
|
|
// }); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths