-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Add parameters kernel.runtime_mode
and kernel.runtime_mode.*
, all set from env var APP_RUNTIME_MODE
#52079
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
Conversation
5e777ad
to
1387951
Compare
src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php
Outdated
Show resolved
Hide resolved
1387951
to
9cb05e6
Compare
9cb05e6
to
54ed084
Compare
shouldn't the error rendering depend on web_mode ? For a long-running server, we would want to provide the web error rendering. |
yes, but it's too much work for me for now, could be handled later on (same for cache locking, see PR description) |
kernel.runtime_mode
, defined as %env(default:container.runtime_mode:APP_RUNTIME_MODE)%
kernel.runtime_mode
and kernel.runtime_mode.*
, all set from env var APP_RUNTIME_MODE
54ed084
to
aaafad1
Compare
PR updated. No special service anymore, only parameters. Here is the new description: Here, we ensure that the kernel always provides a new This also creates 3 new parameters that should be the most common: A long-running server would typically set |
@@ -97,7 +97,7 @@ public static function createSystemCache(string $namespace, int $defaultLifetime | |||
return $opcache; | |||
} | |||
|
|||
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) { | |||
if ('cli' === \PHP_SAPI && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aligning with other checks we have in place for APCu (not need to enable it for phpdbg/embed)
@@ -1591,7 +1592,7 @@ private function addDefaultParametersMethod(): string | |||
$export = $this->exportParameters([$value], '', 12, $hasEnum); | |||
$export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2); | |||
|
|||
if ($hasEnum || preg_match("/\\\$container->(?:getEnv\('(?:[-.\w\\\\]*+:)*+\w++'\)|targetDir\.'')/", $export[1])) { | |||
if ($hasEnum || preg_match("/\\\$container->(?:getEnv\('(?:[-.\w\\\\]*+:)*+\w*+'\)|targetDir\.'')/", $export[1])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change allows to derivate dynamic parameters from other ones, eg %env(key:foo:default:bar:)%
extracts key foo
from parameter bar
(which is supposed to be an array here)
…_mode.*`, all set from env var `APP_RUNTIME_MODE`
aaafad1
to
7c70aec
Compare
} elseif (\function_exists('litespeed_finish_request') && !$this->debug) { | ||
litespeed_finish_request(); | ||
} else { | ||
Response::closeOutputBuffers(0, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike the logic in $response->send()
, we call this unconditionally. The reason is that here, in the runtime, we know we want to flush whatever the SAPI.
Thank you @nicolas-grekas. |
Alternative to #51408. I think this approach is simpler and more powerful.
Here, we ensure that the kernel always provides a new
kernel.runtime_mode
parameter. This parameter is an array derived by default from theAPP_RUNTIME_MODE
env var, using thequery_string
processor.This also creates 3 new parameters that should be the most common:
kernel.runtime_mode.web
,kernel.runtime_mode.cli
, andkernel.runtime_mode.worker
.A long-running server would typically set
APP_RUNTIME_MODE
toweb=1&worker=1
orweb=0&worker=1
when appropriate (eg https://github.com/php-runtime/frankenphp-symfony/ should do so whenFRANKENPHP_WORKER
is set.)I screened the codebase and updated them all except cache pools (where the SAPI is used to enable/disable locking) and error renderers (where the SAPI is used to turn html-rendering on/off.) These require more work that could be done later on. There are a few other remaining usages of
PHP_SAPI
but these look not appropriate for the new flag.