Commit d88fbac4 by Alexander Makarov

Merge pull request #2107 from creocoder/yii2-advanced-app-env-improvement

Cleaner environments for yii2-advanced-app
parents 6ab97d92 86747e89
<?php <?php
$rootDir = dirname(dirname(__DIR__));
$params = array_merge( $params = array_merge(
require($rootDir . '/common/config/params.php'), require(__DIR__ . '/../../common/config/params.php'),
require($rootDir . '/common/config/params-local.php'), require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'), require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php') require(__DIR__ . '/params-local.php')
); );
...@@ -11,15 +9,10 @@ $params = array_merge( ...@@ -11,15 +9,10 @@ $params = array_merge(
return [ return [
'id' => 'app-backend', 'id' => 'app-backend',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'vendorPath' => $rootDir . '/vendor',
'preload' => ['log'], 'preload' => ['log'],
'controllerNamespace' => 'backend\controllers', 'controllerNamespace' => 'backend\controllers',
'modules' => [], 'modules' => [],
'extensions' => require($rootDir . '/vendor/yiisoft/extensions.php'),
'components' => [ 'components' => [
'db' => $params['components.db'],
'cache' => $params['components.cache'],
'mail' => $params['components.mail'],
'user' => [ 'user' => [
'identityClass' => 'common\models\User', 'identityClass' => 'common\models\User',
'enableAutoLogin' => true, 'enableAutoLogin' => true,
......
<?php
Yii::setAlias('common', dirname(__DIR__));
Yii::setAlias('frontend', dirname(dirname(__DIR__)) . '/frontend');
Yii::setAlias('backend', dirname(dirname(__DIR__)) . '/backend');
Yii::setAlias('console', dirname(dirname(__DIR__)) . '/console');
<?php
return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'),
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'mail' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mails',
],
],
];
<?php <?php
Yii::setAlias('common', dirname(__DIR__));
Yii::setAlias('frontend', dirname(dirname(__DIR__)) . '/frontend');
Yii::setAlias('backend', dirname(dirname(__DIR__)) . '/backend');
Yii::setAlias('console', dirname(dirname(__DIR__)) . '/console');
return [ return [
'adminEmail' => 'admin@example.com', 'adminEmail' => 'admin@example.com',
'supportEmail' => 'support@example.com', 'supportEmail' => 'support@example.com',
'components.cache' => [
'class' => 'yii\caching\FileCache',
],
'components.mail' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mails',
],
]; ];
<?php <?php
$rootDir = __DIR__ . '/../..';
$params = array_merge( $params = array_merge(
require($rootDir . '/common/config/params.php'), require(__DIR__ . '/../../common/config/params.php'),
require($rootDir . '/common/config/params-local.php'), require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'), require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php') require(__DIR__ . '/params-local.php')
); );
...@@ -11,15 +9,9 @@ $params = array_merge( ...@@ -11,15 +9,9 @@ $params = array_merge(
return [ return [
'id' => 'app-console', 'id' => 'app-console',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'controllerNamespace' => 'console\controllers', 'controllerNamespace' => 'console\controllers',
'modules' => [ 'modules' => [],
],
'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'),
'components' => [ 'components' => [
'db' => $params['components.db'],
'cache' => $params['components.cache'],
'mail' => $params['components.mail'],
'log' => [ 'log' => [
'targets' => [ 'targets' => [
[ [
......
<?php <?php
return [ return [
'preload' => [
//'debug',
],
'modules' => [
// 'debug' => 'yii\debug\Module',
// 'gii' => 'yii\gii\Module',
],
]; ];
...@@ -4,8 +4,11 @@ defined('YII_ENV') or define('YII_ENV', 'dev'); ...@@ -4,8 +4,11 @@ defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/aliases.php');
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../common/config/main.php'),
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../config/main-local.php') require(__DIR__ . '/../config/main-local.php')
); );
......
<?php
return [
'preload' => [
//'debug',
],
'modules' => [
// 'debug' => 'yii\debug\Module',
// 'gii' => 'yii\gii\Module',
],
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
],
];
<?php <?php
return [ return [
'components.db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
]; ];
<?php <?php
return [ return [
'preload' => [
//'debug',
],
'modules' => [
// 'debug' => 'yii\debug\Module',
// 'gii' => 'yii\gii\Module',
],
]; ];
...@@ -4,8 +4,11 @@ defined('YII_ENV') or define('YII_ENV', 'dev'); ...@@ -4,8 +4,11 @@ defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/aliases.php');
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../common/config/main.php'),
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../config/main-local.php') require(__DIR__ . '/../config/main-local.php')
); );
......
...@@ -19,6 +19,8 @@ require(__DIR__ . '/vendor/autoload.php'); ...@@ -19,6 +19,8 @@ require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/common/config/main.php'),
require(__DIR__ . '/common/config/main-local.php'),
require(__DIR__ . '/console/config/main.php'), require(__DIR__ . '/console/config/main.php'),
require(__DIR__ . '/console/config/main-local.php') require(__DIR__ . '/console/config/main-local.php')
); );
......
...@@ -4,8 +4,11 @@ defined('YII_ENV') or define('YII_ENV', 'prod'); ...@@ -4,8 +4,11 @@ defined('YII_ENV') or define('YII_ENV', 'prod');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/aliases.php');
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../common/config/main.php'),
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../config/main-local.php') require(__DIR__ . '/../config/main-local.php')
); );
......
<?php
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
],
];
<?php <?php
return [ return [
'components.db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
]; ];
...@@ -4,8 +4,11 @@ defined('YII_ENV') or define('YII_ENV', 'prod'); ...@@ -4,8 +4,11 @@ defined('YII_ENV') or define('YII_ENV', 'prod');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/aliases.php');
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../common/config/main.php'),
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../config/main-local.php') require(__DIR__ . '/../config/main-local.php')
); );
......
...@@ -19,6 +19,8 @@ require(__DIR__ . '/vendor/autoload.php'); ...@@ -19,6 +19,8 @@ require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/common/config/main.php'),
require(__DIR__ . '/common/config/main-local.php'),
require(__DIR__ . '/console/config/main.php'), require(__DIR__ . '/console/config/main.php'),
require(__DIR__ . '/console/config/main-local.php') require(__DIR__ . '/console/config/main-local.php')
); );
......
<?php <?php
$rootDir = __DIR__ . '/../..';
$params = array_merge( $params = array_merge(
require($rootDir . '/common/config/params.php'), require(__DIR__ . '/../../common/config/params.php'),
require($rootDir . '/common/config/params-local.php'), require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'), require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php') require(__DIR__ . '/params-local.php')
); );
...@@ -11,13 +9,8 @@ $params = array_merge( ...@@ -11,13 +9,8 @@ $params = array_merge(
return [ return [
'id' => 'app-frontend', 'id' => 'app-frontend',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'vendorPath' => $rootDir . '/vendor',
'controllerNamespace' => 'frontend\controllers', 'controllerNamespace' => 'frontend\controllers',
'extensions' => require($rootDir . '/vendor/yiisoft/extensions.php'),
'components' => [ 'components' => [
'db' => $params['components.db'],
'cache' => $params['components.cache'],
'mail' => $params['components.mail'],
'user' => [ 'user' => [
'identityClass' => 'common\models\User', 'identityClass' => 'common\models\User',
'enableAutoLogin' => true, 'enableAutoLogin' => true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment