Commit a4c8617f by Alexander Kochetov

Cleaner environments for yii2-advanced-app

parent 4fe0eeb1
<?php <?php
$rootDir = dirname(dirname(__DIR__));
$params = array_merge(
require($rootDir . '/common/config/params.php'),
require($rootDir . '/common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
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,
...@@ -37,5 +23,10 @@ return [ ...@@ -37,5 +23,10 @@ return [
'errorAction' => 'site/error', 'errorAction' => 'site/error',
], ],
], ],
'params' => $params, 'params' => array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.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 [
'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(
require($rootDir . '/common/config/params.php'),
require($rootDir . '/common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
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' => [
[ [
...@@ -29,5 +14,10 @@ return [ ...@@ -29,5 +14,10 @@ return [
], ],
], ],
], ],
'params' => $params, 'params' => array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
),
]; ];
...@@ -6,6 +6,8 @@ require(__DIR__ . '/../../vendor/autoload.php'); ...@@ -6,6 +6,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__ . '/../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',
],
]; ];
...@@ -6,6 +6,8 @@ require(__DIR__ . '/../../vendor/autoload.php'); ...@@ -6,6 +6,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__ . '/../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')
); );
......
...@@ -6,6 +6,8 @@ require(__DIR__ . '/../../vendor/autoload.php'); ...@@ -6,6 +6,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__ . '/../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',
],
]; ];
...@@ -6,6 +6,8 @@ require(__DIR__ . '/../../vendor/autoload.php'); ...@@ -6,6 +6,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__ . '/../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(
require($rootDir . '/common/config/params.php'),
require($rootDir . '/common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
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,
...@@ -35,5 +21,10 @@ return [ ...@@ -35,5 +21,10 @@ return [
'errorAction' => 'site/error', 'errorAction' => 'site/error',
], ],
], ],
'params' => $params, 'params' => array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
),
]; ];
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