Active
Project:
Drupal core
Version:
main
Component:
base system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 May 2024 at 17:00 UTC
Updated:
2 Mar 2026 at 09:36 UTC
Jump to comment: Most recent
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.
Update index.php and document APP_ENV
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
andypostThere's https://symfony.com/components/Dotenv
Comment #3
andypostComment #4
mglamanThis isn't about adding a package to load env files, but just allowing customizing the parameter without managing index.php yourself
Comment #5
andypostThen it should use
getenv()as the rest of testing code doingComment #6
mglamanA 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
Comment #7
mglamanComment #10
kingdutchI'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
$_ENVwhich follows the default recommendation fromsymfony/dotenvand 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.