Skip to content

Commit cda6803

Browse files
committed
feature #52079 [HttpKernel] Add parameters kernel.runtime_mode and kernel.runtime_mode.*, all set from env var APP_RUNTIME_MODE (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- [HttpKernel] Add parameters `kernel.runtime_mode` and `kernel.runtime_mode.*`, all set from env var `APP_RUNTIME_MODE` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #51340 | License | MIT | Doc PR | TODO 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 the `APP_RUNTIME_MODE` env var, using the `query_string` processor. This also creates 3 new parameters that should be the most common: `kernel.runtime_mode.web`, `kernel.runtime_mode.cli`, and `kernel.runtime_mode.worker`. A long-running server would typically set `APP_RUNTIME_MODE` to `web=1&worker=1` or `web=0&worker=1` when appropriate (eg https://github.com/php-runtime/frankenphp-symfony/ should do so when `FRANKENPHP_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. Commits ------- 7c70aec37ad [HttpKernel] Add parameters `kernel.runtime_mode` and `kernel.runtime_mode.*`, all set from env var `APP_RUNTIME_MODE`
2 parents 3f6f255 + bb124a1 commit cda6803

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con
11841184
$container->setDefinition('debug.log_processor', $definition);
11851185

11861186
$container->register('debug.debug_logger_configurator', DebugLoggerConfigurator::class)
1187-
->setArguments([new Reference('debug.log_processor')]);
1187+
->setArguments([new Reference('debug.log_processor'), '%kernel.runtime_mode.web%']);
11881188
}
11891189
}
11901190

Resources/config/debug_prod.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
->tag('monolog.logger', ['channel' => 'php'])
3333

3434
->set('debug.debug_handlers_listener', DebugHandlersListener::class)
35+
->args([null, param('kernel.runtime_mode.web')])
3536
->tag('kernel.event_subscriber')
3637

3738
->set('debug.file_link_formatter', FileLinkFormatter::class)

0 commit comments

Comments
 (0)