How to use FrankenPHP with RequestStack #685
Replies: 1 comment 5 replies
-
Hi @stephanvierkant! Can you tell us more about the problem you encountered when using
From the example of the Example of statefull service (bad practicle) class SomeValueStorage
{
private ?string $someValue = null;
public function __construct(
private readonly RequestStack $requestStack,
) {
}
public function getSomeRequestedValue(): string
{
if (null !== $this->someValue) {
return $this->someValue;
}
$request = $this->requestStack->getCurrentRequest();
$someValue = $this->resolveSomeValue($request);
$this->someValue = $someValue;
return $someValue;
}
private function resolveSomeValue(Reuqest $request): string
{
// some heavy operations to resolve target value
}
} A class like this should be modified to not save its state. For this example, there are two options:
In both cases, the service loses the property that stores the state of the service, which makes this service stateless. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've used this template to get my webapplication running Docker. Almost everything works fine now, but I'm using a couple of services with RequestStack.
After some time of debugging, I found out this doesn't work great with FrankenPHP.
But how do I fix this? For now I disabled FrankenPHP, but I guess this should be doable. I already found the ResetInterface, but I can't find good examples how to use it. Given the example, should
NewsletterManager
implementSymfony\Contracts\Service\ResetInterface
?update:
Let's say I've got something like this:
Beta Was this translation helpful? Give feedback.
All reactions