Skip to content

Commit 70379b6

Browse files
author
Angel Garcia
committed
Added Local environment configuration
1 parent c66a1cb commit 70379b6

File tree

14 files changed

+235
-65
lines changed

14 files changed

+235
-65
lines changed

environments/index.php

Lines changed: 41 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,44 @@
11
<?php
2-
/**
3-
* The manifest of files that are local to specific environment.
4-
* This file returns a list of environments that the application
5-
* may be installed under. The returned data must be in the following
6-
* format:
7-
*
8-
* ```php
9-
* return [
10-
* 'environment name' => [
11-
* 'path' => 'directory storing the local files',
12-
* 'skipFiles' => [
13-
* // list of files that should only copied once and skipped if they already exist
14-
* ],
15-
* 'setWritable' => [
16-
* // list of directories that should be set writable
17-
* ],
18-
* 'setExecutable' => [
19-
* // list of files that should be set executable
20-
* ],
21-
* 'setCookieValidationKey' => [
22-
* // list of config files that need to be inserted with automatically generated cookie validation keys
23-
* ],
24-
* 'createSymlink' => [
25-
* // list of symlinks to be created. Keys are symlinks, and values are the targets.
26-
* ],
27-
* ],
28-
* ];
29-
* ```
30-
*/
31-
return [
32-
'Development' => [
33-
'path' => 'dev',
34-
'setWritable' => [
35-
'backend/runtime',
36-
'backend/web/assets',
37-
'console/runtime',
38-
'frontend/runtime',
39-
'frontend/web/assets',
40-
],
41-
'setExecutable' => [
42-
'yii',
43-
'yii_test',
44-
],
45-
'setCookieValidationKey' => [
46-
'backend/config/main-local.php',
47-
'common/config/codeception-local.php',
48-
'frontend/config/main-local.php',
49-
],
2+
/**
3+
* The manifest of files that are local to specific environment.
4+
* This file returns a list of environments that the application
5+
* may be installed under. The returned data must be in the following
6+
* format:
7+
*
8+
* ```php
9+
* return [
10+
* 'environment name' => [
11+
* 'path' => 'directory storing the local files',
12+
* 'skipFiles' => [
13+
* // list of files that should only copied once and skipped if they already exist
14+
* ],
15+
* 'setWritable' => [
16+
* // list of directories that should be set writable
17+
* ],
18+
* 'setExecutable' => [
19+
* // list of files that should be set executable
20+
* ],
21+
* 'setCookieValidationKey' => [
22+
* // list of config files that need to be inserted with automatically generated cookie validation keys
23+
* ],
24+
* 'createSymlink' => [
25+
* // list of symlinks to be created. Keys are symlinks, and values are the targets.
26+
* ],
27+
* ],
28+
* ];
29+
* ```
30+
*/
31+
return [
32+
'Local' => [
33+
'path' => 'local',
34+
'setWritable' => [
35+
'api/runtime',
36+
'console/runtime',
5037
],
51-
'Production' => [
52-
'path' => 'prod',
53-
'setWritable' => [
54-
'backend/runtime',
55-
'backend/web/assets',
56-
'console/runtime',
57-
'frontend/runtime',
58-
'frontend/web/assets',
59-
],
60-
'setExecutable' => [
61-
'yii',
62-
],
63-
'setCookieValidationKey' => [
64-
'backend/config/main-local.php',
65-
'frontend/config/main-local.php',
66-
],
38+
'setExecutable' => [
39+
'yii',
40+
'yii_test',
6741
],
68-
];
42+
'setCookieValidationKey' => [],
43+
],
44+
];
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
$config = [
4+
'components' => [
5+
'request' => [
6+
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
7+
'cookieValidationKey' => '',
8+
],
9+
],
10+
];
11+
12+
if (!YII_ENV_TEST) {
13+
// configuration adjustments for 'dev' environment
14+
$config['bootstrap'][] = 'debug';
15+
$config['modules']['debug'] = [
16+
'class' => 'yii\debug\Module',
17+
];
18+
19+
$config['bootstrap'][] = 'gii';
20+
$config['modules']['gii'] = [
21+
'class' => 'yii\gii\Module',
22+
];
23+
}
24+
25+
return $config;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
return [
3+
];
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
return yii\helpers\ArrayHelper::merge(
3+
require(__DIR__ . '/../../common/config/test-local.php'),
4+
require(__DIR__ . '/main.php'),
5+
require(__DIR__ . '/main-local.php'),
6+
require(__DIR__ . '/test.php'),
7+
[
8+
]
9+
);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
// NOTE: Make sure this file is not accessible when deployed to production
4+
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
5+
die('You are not allowed to access this file.');
6+
}
7+
8+
defined('YII_DEBUG') or define('YII_DEBUG', true);
9+
defined('YII_ENV') or define('YII_ENV', 'test');
10+
11+
require(__DIR__ . '/../../vendor/autoload.php');
12+
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
13+
require(__DIR__ . '/../../common/config/bootstrap.php');
14+
require(__DIR__ . '/../config/bootstrap.php');
15+
16+
$config = require(__DIR__ . '/../config/test-local.php');
17+
18+
(new yii\web\Application($config))->run();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
defined('YII_DEBUG') or define('YII_DEBUG', true);
3+
defined('YII_ENV') or define('YII_ENV', 'dev');
4+
5+
require(__DIR__ . '/../../vendor/autoload.php');
6+
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
7+
require(__DIR__ . '/../../common/config/bootstrap.php');
8+
require(__DIR__ . '/../config/bootstrap.php');
9+
10+
$config = yii\helpers\ArrayHelper::merge(
11+
require(__DIR__ . '/../../common/config/main.php'),
12+
require(__DIR__ . '/../../common/config/main-local.php'),
13+
require(__DIR__ . '/../config/main.php'),
14+
require(__DIR__ . '/../config/main-local.php')
15+
);
16+
17+
(new yii\web\Application($config))->run();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
return [
3+
'components' => [
4+
'db' => [
5+
'class' => 'yii\db\Connection',
6+
'dsn' => 'mysql:host=localhost;dbname=api_db',
7+
'username' => 'root',
8+
'password' => '',
9+
'charset' => 'utf8',
10+
],
11+
'mailer' => [
12+
'class' => 'yii\swiftmailer\Mailer',
13+
'viewPath' => '@common/mail',
14+
// send all mails to a file by default. You have to set
15+
// 'useFileTransport' to false and configure a transport
16+
// for the mailer to send real emails.
17+
'useFileTransport' => true,
18+
],
19+
],
20+
];
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
return [
3+
'CORS' => ['https://localhost:8080', 'http://localhost:8080']
4+
];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
return yii\helpers\ArrayHelper::merge(
3+
require(__DIR__ . '/main.php'),
4+
require(__DIR__ . '/main-local.php'),
5+
require(__DIR__ . '/test.php'),
6+
[
7+
'components' => [
8+
'db' => [
9+
'dsn' => 'mysql:host=localhost;dbname=yii2advanced_test',
10+
]
11+
],
12+
]
13+
);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
return [
3+
'bootstrap' => ['gii'],
4+
'modules' => [
5+
'gii' => 'yii\gii\Module',
6+
],
7+
];

0 commit comments

Comments
 (0)