Problem/Motivation
#3313404: Use symfony/runtime for less bespoke bootstrap/compatibility with varied runtime environments added DrupalRuntime but kept the changes to the front-controller minimal. The front-controllers still contain hardcoded inputs to DrupalKernel (e.g. the autoload require and environment). This means that these things still require changes to the front-controllers rather than being able to control these based on the environment.
Steps to reproduce
Proposed resolution
Implement DrupalKernel::getArgument so that we can make the arguments currently hardcoded to DrupalKernel available as argument injections to the main front-controller function.
The project directory is provided by Symfony's autoload_runtime.php file. If it does not exist then we find the project directory based on Composer's ClassLoader location.
Remaining tasks
User interface changes
Introduced terminology
API changes
Front controllers can now inject the following variables into their main application function:
string $environment- The current environment orprodby default. The environment is read from$_SERVER['APP_ENV']or$_ENV['APP_ENV']by default. This behavior can be changed by configuring runtime options- Any variable type-hinted with
ClassLoaderwill contain the composer autoloader as if runningrequire vendor/autoload.php.
Data model changes
Release notes snippet
Issue fork drupal-3589604
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
kingdutchI thought I could immediately tackle
$app_root, but that is actually slightly different from$project_dirand also depends on whether Drupal is inside of its own development repository or a Drupal based application, so I'm keeping it out of scope for now and keeping strictly to the follow-up from #3313404: Use symfony/runtime for less bespoke bootstrap/compatibility with varied runtime environments as well as usingRequest $requestwherever possible, which we get for free fromSymfonyRuntime.$app_rootwill then be tackled in #1792310: Wrong DRUPAL_ROOT with non-standard code structure and #2529170: [PP-1] Remove DrupalKernel::initializeRequestGlobals and replace base_root, base_url and base_path with a service collectively.Comment #4
kingdutchThis also solves #2501901: Allow configuring the environment via an environment variable