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