-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use env variables instead of constants #193
Conversation
rustamwin
commented
Sep 16, 2021
Q | A |
---|---|
Is bugfix? | ❌ |
New feature? | ✔️ |
Breaks BC? | ✔️/❌ |
Fixed issues | #190 |
What about moving require_once __DIR__ . '/vendor/autoload.php'
$dotenv = Dotenv::createImmutable(dirname(__DIR__, 2));
$dotenv->load();
$_ENV['YII_ENV'] = empty($_ENV['YII_ENV'])
? self::DEFAULT_YII_ENV
: (string)$_ENV['YII_ENV'];
$_SERVER['YII_ENV'] = $_ENV['YII_ENV'];
$_ENV['YII_DEBUG'] = empty($_ENV['YII_DEBUG'])
? self::DEFAULT_YII_DEBUG
: filter_var(
$_ENV['YII_DEBUG'],
FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE
) ?? self::DEFAULT_YII_DEBUG;
$_SERVER['YII_DEBUG'] = $_ENV['YII_DEBUG'];
if ($_ENV['YII_ENV'] === 'test') {
$c3 = dirname(__DIR__) . '/c3.php';
if (is_file($c3)) {
require_once $c3;
}
} In that case we can get rid of an |
Getting rid of index-test.php is a good idea. |
…oints to psalm (#192)
@rustamwin would you please resolve conflicts and try @BoShurik idea? |
Yes. |
Config is created in entry points: $config = new Config(
dirname(__DIR__, 2),
'/config/packages', // Configs path.
$this->environment,
[
'params',
'events',
'events-web',
'events-console',
],
); Root path, configs paths and recursive merge groups should be same in all entry points. Maybe create |
Co-authored-by: Sergei Predvoditelev <[email protected]>
Co-authored-by: Sergei Predvoditelev <[email protected]>
The name of the file is the same as |
@@ -0,0 +1,2 @@ | |||
YII_ENV= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about proving a default value here?
YII_ENV= | |
YII_ENV=dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value is '/'. See config plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's usually not only config environment.
@@ -0,0 +1,2 @@ | |||
YII_ENV= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's usually not only config environment.
👍 Would you please apply that to app-api, demo and demo-api as well? |
Yes. |