File tree Expand file tree Collapse file tree 2 files changed +22
-11
lines changed
Expand file tree Collapse file tree 2 files changed +22
-11
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env php
22<?php
33
4- if (getenv ('ENV_DIR ' ) !== false && getenv ('ENV_DIR ' ) !== '' ) {
5- $ _SERVER ['APP_RUNTIME_OPTIONS ' ]['dotenv_path ' ] = getenv ('ENV_DIR ' ).'/.env ' ;
4+ $ overridenEnvDir = getenv ('ENV_DIR ' ) ?: null ;
5+
6+ if ($ overridenEnvDir ) {
7+ // Tell the Runtime not to touch dotenv so we can load our own file.
8+ // This is needed if the ENV_DIR is outside of the project directory
9+ $ _SERVER ['APP_RUNTIME_OPTIONS ' ]['disable_dotenv ' ] = true ;
610}
711
812use App \Kernel ;
@@ -19,11 +23,12 @@ if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
1923
2024require_once dirname (__DIR__ ).'/vendor/autoload_runtime.php ' ;
2125
22- return function ( array $ context ) {
23-
24- $ env_dir = getenv ( ' ENV_DIR ' ) != false ? getenv ( ' ENV_DIR ' ) : dirname ( __DIR__ );
25- ( new Dotenv ())-> bootEnv ( $ env_dir . ' /.env ' );
26+ if ( $ overridenEnvDir ) {
27+ // Load our own now, after the runtime has booted
28+ ( new Dotenv ())-> bootEnv ( $ overridenEnvDir . ' /.env ' );
29+ }
2630
31+ return function (array $ context ) {
2732 $ kernel = new Kernel ($ context ['APP_ENV ' ], (bool ) $ context ['APP_DEBUG ' ]);
2833
2934 return new Application ($ kernel );
Original file line number Diff line number Diff line change 11<?php
22
3- if (false !== getenv ('ENV_DIR ' ) && '' !== getenv ('ENV_DIR ' )) {
4- $ _SERVER ['APP_RUNTIME_OPTIONS ' ]['dotenv_path ' ] = getenv ('ENV_DIR ' ).'/.env ' ;
3+ $ overridenEnvDir = getenv ('ENV_DIR ' ) ?: null ;
4+
5+ if ($ overridenEnvDir ) {
6+ // Tell the Runtime not to touch dotenv so we can load our own file.
7+ // This is needed if the ENV_DIR is outside of the project directory
8+ $ _SERVER ['APP_RUNTIME_OPTIONS ' ]['disable_dotenv ' ] = true ;
59}
610
711use App \Kernel ;
812use Symfony \Component \Dotenv \Dotenv ;
913
1014require_once dirname (__DIR__ ).'/vendor/autoload_runtime.php ' ;
1115
12- return function (array $ context ) {
13- $ env_dir = false != getenv ('ENV_DIR ' ) ? getenv ('ENV_DIR ' ) : dirname (__DIR__ );
14- (new Dotenv ())->bootEnv ($ env_dir .'/.env ' );
16+ if ($ overridenEnvDir ) {
17+ // Load our own now, after the runtime has booted
18+ (new Dotenv ())->bootEnv ($ overridenEnvDir .'/.env ' );
19+ }
1520
21+ return function (array $ context ) {
1622 return new Kernel ($ context ['APP_ENV ' ], (bool ) $ context ['APP_DEBUG ' ]);
1723};
You can’t perform that action at this time.
0 commit comments