Skip to content
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

Merged
merged 24 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YII_ENV=/
YII_DEBUG=true
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"psr/http-message": "^1.0",
"psr/http-server-handler": "^1.0",
"symfony/console": "^5.3",
"vlucas/phpdotenv": "^5.3",
"yiisoft/aliases": "^2.0",
"yiisoft/assets": "^1.0",
"yiisoft/cache": "^1.0",
Expand Down
16 changes: 3 additions & 13 deletions public/index-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,9 @@

require_once dirname(__DIR__) . '/vendor/autoload.php';

/**
* Set debug value for web application runner, for default its `true` add additionally the validation of the
* container-di configurations (debug mode).
*/
define('YII_DEBUG', getenv('YII_DEBUG') ?: true);

/**
* Set environment value for web application runner, for default its `null`.
*
* @link https://github.com/yiisoft/config#environments
*/
define('YII_ENV', getenv('YII_ENV') ?: null);
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__));
$dotenv->load();

// Run web application runner
$runner = new WebApplicationRunner(YII_DEBUG, YII_ENV);
$runner = new WebApplicationRunner(filter_var($_ENV['YII_DEBUG'], FILTER_VALIDATE_BOOL, FILTER_NULL_ON_FAILURE), $_ENV['YII_ENV']);
$runner->run();
16 changes: 3 additions & 13 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,9 @@

require_once dirname(__DIR__) . '/vendor/autoload.php';

/**
* Set debug value for web application runner, for default its `true` add additionally the validation of the
* container-di configurations (debug mode).
*/
define('YII_DEBUG', getenv('YII_DEBUG') ?: true);

/**
* Set environment value for web application runner, for default its `null`.
*
* @link https://github.com/yiisoft/config#environments
*/
define('YII_ENV', getenv('YII_ENV') ?: null);
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__));
$dotenv->load();

// Run web application runner
$runner = new WebApplicationRunner(YII_DEBUG, YII_ENV);
$runner = new WebApplicationRunner(filter_var($_ENV['YII_DEBUG'], FILTER_VALIDATE_BOOL, FILTER_NULL_ON_FAILURE), $_ENV['YII_ENV']);
$runner->run();
20 changes: 5 additions & 15 deletions yii
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,9 @@ use App\Runner\ConsoleApplicationRunner;

require_once __DIR__ . '/vendor/autoload.php';

/**
* Set debug value for console application runner, for default its `true` add additionally the validation of the
* container-di configurations (debug mode).
*/
define('YII_DEBUG', getenv('YII_DEBUG') ?: true);
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__));
$dotenv->load();

/**
* Set environment value for web application runner, for default its `null`.
*
* @link https://github.com/yiisoft/config#environments
*/
define('YII_ENV', getenv('YII_ENV') ?: null);

// Run console application runner
$consoleRunner = new ConsoleApplicationRunner(YII_DEBUG, YII_ENV);
$consoleRunner->run();
// Run web application runner
rustamwin marked this conversation as resolved.
Show resolved Hide resolved
$runner = new ConsoleApplicationRunner(filter_var($_ENV['YII_DEBUG'], FILTER_VALIDATE_BOOL, FILTER_NULL_ON_FAILURE), $_ENV['YII_ENV']);
$runner->run();