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 or prod by 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 ClassLoader will contain the composer autoloader as if running require vendor/autoload.php.

Data model changes

Release notes snippet

Issue fork drupal-3589604

Command icon 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

kingdutch created an issue. See original summary.

kingdutch’s picture

Assigned: kingdutch » Unassigned
Issue summary: View changes
Status: Active » Needs review

I thought I could immediately tackle $app_root, but that is actually slightly different from $project_dir and 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 using Request $request wherever possible, which we get for free from SymfonyRuntime.

$app_root will 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.