Problem/Motivation

In the DrupalKernel we have an environment argument. However, it's always hardcoded to be prod:

$kernel = new DrupalKernel('prod', $autoloader);

It'd be better if we used an environment variable like other platforms:

$kernel = new DrupalKernel(getnev('APP_ENV') ?? 'prod', $autoloader);

Spun out of discussions in #3445816: Making Drupal automatically installable with default environment variables.

Proposed resolution

Update index.php and document APP_ENV

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3446545

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

mglaman created an issue. See original summary.

andypost’s picture

mglaman’s picture

This isn't about adding a package to load env files, but just allowing customizing the parameter without managing index.php yourself

andypost’s picture

Then it should use getenv() as the rest of testing code doing

mglaman’s picture

A discussion in #3445816: Making Drupal automatically installable with default environment variables went from getenv to $_ENV. I'm somewhat indifferent; whatever makes this land faster. There are benefits to each. But if Drupal core is already using getenv then I'll switch

mglaman’s picture

Issue summary: View changes

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

kingdutch made their first commit to this issue’s fork.

kingdutch’s picture

I've added https://git.drupalcode.org/issue/drupal-3446545/-/commit/99fc802a81b51b7... which is what the implementation would look like once #3313404: Use symfony/runtime for less bespoke bootstrap/compatibility with varied runtime environments lands.

That implementation uses $_ENV which follows the default recommendation from symfony/dotenv and the ongoing work in #3445816: Making Drupal automatically installable with default environment variables. Using the options for the runtime, dotenv integration can trivially be enabled.