This extension replaces value object Http\Request
that is used as a service,
with a RequestStack
that can hold onto Http\Request
and change it in runtime.
You can install the extension using this command
$ composer require kdyby/request-stack
and enable the extension using your neon config.
extensions:
requestStack: Kdyby\RequestStack\DI\RequestStackExtension
Everywhere where you depend on Http\Request
in your application, you have to replace it with Http\IRequest
.
This allows for the RequestStack
to be injected instead.
When you want to change the Http\Request
object, you simply call
$httpRequestStack->pushRequest(new Http\Request(
new UrlScript('https://www.kdyby.org/?some=query'),
NULL, // deprecated
[], // post
[], // files
[], // cookies
[], // headers
'GET', // HTTP method
'127.0.0.1', // remote address
'127.0.0.1' // remote host
));
And that's it.