-
-
Notifications
You must be signed in to change notification settings - Fork 36
feat: add middleware to FrankenPhpSymfony #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add middleware to FrankenPhpSymfony #183
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