Slim-Bridge icon indicating copy to clipboard operation
Slim-Bridge copied to clipboard

Request attributes are being overridden

Open KevinMarques opened this issue 6 months ago • 4 comments

This PR https://github.com/PHP-DI/Slim-Bridge/pull/84 is causing the request attributes to be overriden.

As stated in the Slim official documentation:

With PSR-7 it is possible to inject objects/values into the request object for further processing. In your applications middleware often need to pass along information to your route closure and the way to do it is to add it to the request object via an attribute.

So you can for example have a middleware which sets in the request an attribute called "user" and have also a route with a "user" named argument, causing PHP-DI Slim bridge to override the original attribute value.

The Slim documented way to access route parameters is with $route->getArgument('id') function, so maybe the original issue here was the PHP-DI slim bridge documentation indicating a missuse of getAttribute function.

KevinMarques avatar Dec 11 '23 12:12 KevinMarques