implementing PHP 8.2 and PSR-15 Middleware Not Executing in Order with Symfony
I'm converting an old project and This might be a silly question, but I'm working with a question with my Symfony application where the PSR-15 middleware isn't executing in the order I expected. I'm using PHP 8.2 along with Symfony 6.2, and my middleware is defined in the service configuration. I have three middleware components that are supposed to log requests, check authentication, and handle CORS, but the CORS handling seems to be executing before the authentication check. Here's how I configured my middleware: ```yaml # config/services.yaml services: App\Middleware\RequestLogger: tags: - { name: 'middleware' } App\Middleware\Authentication: tags: - { name: 'middleware' } App\Middleware\CorsHandler: tags: - { name: 'middleware' } ``` I expected the order of execution to be RequestLogger -> Authentication -> CorsHandler, but it seems like the order is being altered. To debug this, I've added logging at the beginning of each middleware: ```php public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { error_log('RequestLogger executed'); return $handler->handle($request); } ``` I see the log for `RequestLogger` but the next one is for `CorsHandler` instead of `Authentication`. I've checked the documentation for Symfony and PSR-15, and I need to find anything indicating that the order is affected by anything. I've also tried explicitly defining the order in the service tags with additional parameters, but it seems that Symfony ignores them. Could there be something I'm missing about how middleware order is determined in Symfony 6.2? Any suggestions would be greatly appreciated. I'm working on a application that needs to handle this. Am I missing something obvious? I'm working on a application that needs to handle this. Has anyone else encountered this? Thanks for your help in advance!