feat: add middleware to FrankenPhpSymfony#183
feat: add middleware to FrankenPhpSymfony#183Scarbous wants to merge 2 commits intophp-runtime:mainfrom
Conversation
|
FYI, in Symfony 7.4, support for FrankenPHP will work out of the box, no php-runtime package will be required. |
|
Thank you @nicolas-grekas, I will add the middleware PR also for the runtime in symfony. |
bea4709 to
410eaa3
Compare
|
Is it necessary to use low-level middleware, but not to decorate Symfony's kernel instance, which would provide a generic solution? |
|
@andrew-demb I have considered using Symfony events, but I would like to be able to wrap the entire handle process. I want to use a middleware for tideways like this: class TidewaysMiddleware implements MiddlewareInterface
{
public function wrap(callable $handler, array $server): void
{
if (!$this->checkTideways()) {
$handler();
return;
}
\Tideways\Profiler::start();
try {
$handler();
} catch (\Throwable $e) {
\Tideways\Profiler::logException($e);
throw $e;
} finally {
\Tideways\Profiler::stop();
}
}
private function checkTideways(): bool
{
return !class_exists('Tideways\Profiler') && !\Tideways\Profiler::isEnabled();
}
} |
|
I’m actually working on exactly the same thing 😅 From my tests, there’s no need to manually handle \Tideways\Profiler::logException — it already integrates with Symfony’s ErrorHandler natively. |
|
@Scarbous I'm talking about the kernel's decorator, not kernel events. It will cover the full handle process, and will be generic, not just for frankenphp |
We use tideways in our projects.
We want to use this middleware to enable the request based profiling.
https://support.tideways.com/documentation/setup/installation/frankenphp.html#code-changes-to-frankenphp_handle_request-callback