Skip to content

Commit

Permalink
Use separate app config files for web/console requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Welch committed Mar 30, 2020
1 parent d41d45d commit 5e06222
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
19 changes: 19 additions & 0 deletions cms/config/app.console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Yii Console Application Config
*
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app.php and app.[web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
*
* You can define custom modules and system components, and even override the
* built-in system components.
*
* This application config is applied only for *only* console requests
*/

return [
];
17 changes: 5 additions & 12 deletions cms/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app/main.php and [web|console].php, when
* vendor/craftcms/cms/src/config/app.php and app.[web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
*
* You can define custom modules and system components, and even override the
* built-in system components.
*
* If you want to modify the application config for *only* web requests or
* *only* console requests, create an app.web.php or app.console.php file in
* your config/ folder, alongside this one.
*/

return [
Expand Down Expand Up @@ -38,16 +42,5 @@
'database' => getenv('REDIS_CRAFT_DB'),
],
],
'session' => [
'class' => \yii\redis\Session::class,
'redis' => [
'hostname' => getenv('REDIS_HOSTNAME'),
'port' => getenv('REDIS_PORT'),
'database' => getenv('REDIS_CRAFT_DB'),
],
'as session' => [
'class' => \craft\behaviors\SessionBehavior::class,
],
],
],
];
32 changes: 32 additions & 0 deletions cms/config/app.web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Yii Web Application Config
*
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app.php and app.[web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
*
* You can define custom modules and system components, and even override the
* built-in system components.
*
* This application config is applied only for *only* web requests
*/

return [
'components' => [
'session' => [
'class' => \yii\redis\Session::class,
'redis' => [
'hostname' => getenv('REDIS_HOSTNAME'),
'port' => getenv('REDIS_PORT'),
'database' => getenv('REDIS_CRAFT_DB'),
],
'as session' => [
'class' => \craft\behaviors\SessionBehavior::class,
],
],
],
];

0 comments on commit 5e06222

Please sign in to comment.