Skip to content

Commit

Permalink
Merge branch 'release/1.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Dec 8, 2017
2 parents ab71bf5 + 1042921 commit 462f4d0
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 19 deletions.
43 changes: 42 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
# CRAFT ENVIRONMENT / aaw -- 2016.12.04
# Craft .gitignore
#
# Example .gitignore file for Craft CMS
#
# @author nystudio107
# @copyright Copyright (c) 2017 nystudio107
# @link https://nystudio107.com/
# @package nystudio107/craft
# @since 1.0.0
# @license MIT

# This file should be renamed to '.gitignore' and placed in your
# Craft CMS project root directory

# CRAFT ENVIRONMENT
.env.php
.env.sh
.env

# BUILD FILES
/bower_components/*
/node_modules/*
/build/*
/yarn-error.log
/npm-debug.log

# MISC FILES
.cache
.DS_Store
.idea
.project
.settings
*.esproj
*.sublime-workspace
*.sublime-project
*.tmproj
*.tmproject
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
config.codekit3
prepros-6.config
39 changes: 25 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
# Craft-Multi-Environment Changelog

## 1.0.6 - 2017.12.07
### Changed
* Updated the default CME config to be in line with the Craft 3 version, in terms of the `custom` sub-array
* Updated the `.gitignore` for popular editors

## 1.0.5 - 2017.02.20
### Changed
* Handle load balancing and shared environments better via a check for `HTTP_X_FORWARDED_PROTO` in the protocol
* General code cleanup

## 1.0.4 - 2017.01.02

* [Improved] Refactored the `example.env.php` to set the `CRAFTENV` vars in an array, and auto-prefix them programatically
* [Improved] Updated README.md
### Changed
* Refactored the `example.env.php` to set the `CRAFTENV` vars in an array, and auto-prefix them programatically
* Updated README.md

## 1.0.3 - 2016.11.30
### Added
* Added `CRAFTENV_CRAFT_ENVIRONMENT` so that the `CRAFT_ENVIRONMENT` constant is set via `.env.php`
* Renamed `env` to `craftEnd`, accessible via `{{ craft.config.craftEnv }}`
* Added an example Forge configuration in `forge-example`

* [Added] Added `CRAFTENV_CRAFT_ENVIRONMENT` so that the `CRAFT_ENVIRONMENT` constant is set via `.env.php`
* [Added] Renamed `env` to `craftEnd`, accessible via `{{ craft.config.craftEnv }}`
* [Added] Added an example Forge configuration in `forge-example`
* [Improved] Updated README.md
### Changed
* Updated README.md

## 1.0.2 - 2016.11.09
### Added
* Added the `env` variable to `general.php`, accessible via `{{ craft.config.env }}`

* [Added] Added the `env` variable to `general.php`, accessible via `{{ craft.config.env }}`
* [Improved] Updated README.md
### Changed
* Updated README.md

## 1.0.1 - 2016.11.02
### Added
* Added support for `CRAFTENV_SITE_URL`

* [Added] Added support for `CRAFTENV_SITE_URL`
* [Improved] Clarified the usage for `CRAFTENV_BASE_URL` & `CRAFTENV_BASE_PATH`
* [Improved] Updated README.md
### Changed
* Clarified the usage for `CRAFTENV_BASE_URL` & `CRAFTENV_BASE_PATH`
* Updated README.md

## 1.0.0 - 2016.11.01

* [Improved] Initial release
### Changed
* Initial release
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ You should also update the `example.env.php` to include any settings you add, fo

You can access any variables defined in the `general.php` file in Twig via `{{ craft.config }}`. e.g.:

{% if craft.config.craftEnv == "local" %}
{% if craft.config.custom.craftEnv == "local" %}
{% endif %}

The `custom` sub-array in the config setup is for any non-Craft defined config settings that you might want to include in `general.php`. Since Craft does a recursive merge on the config settings, you can change just the config settings you need on a per-environment basis.

### Production via webserver config

It's perfectly fine to use CME as discussed above in a production environment. However, if you want an added measure of security and performance, you can set up your webserver to set the same globally accessible settings via webserver config.
Expand Down
17 changes: 16 additions & 1 deletion craft/config/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
'useEmailAsUsername' => true,
'generateTransformsBeforePageLoad' => true,
'siteUrl' => getenv('CRAFTENV_SITE_URL'),
'craftEnv' => CRAFT_ENVIRONMENT,
'defaultSearchTermOptions' => array(
'subLeft' => true,
'subRight' => true,
Expand All @@ -28,26 +27,42 @@
'baseUrl' => getenv('CRAFTENV_BASE_URL'),
'basePath' => getenv('CRAFTENV_BASE_PATH'),
),
// Custom site-specific config settings
'custom' => array(
'basePath' => getenv('CRAFTENV_BASE_PATH'),
'baseUrl' => getenv('CRAFTENV_BASE_URL'),
'craftEnv' => CRAFT_ENVIRONMENT,
'staticAssetsVersion' => 1,
),
),

// Live (production) environment
'live' => array(
'devMode' => false,
'enableTemplateCaching' => true,
'allowAutoUpdates' => false,
// Custom site-specific config settings
'custom' => array(
),
),

// Staging (pre-production) environment
'staging' => array(
'devMode' => false,
'enableTemplateCaching' => true,
'allowAutoUpdates' => false,
// Custom site-specific config settings
'custom' => array(
),
),

// Local (development) environment
'local' => array(
'devMode' => true,
'enableTemplateCaching' => false,
'allowAutoUpdates' => true,
// Custom site-specific config settings
'custom' => array(
),
),
);
6 changes: 4 additions & 2 deletions example.env.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
} else {
$protocol = "http://";
}
// Determine the server hostname
$httpHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
// The $craftEnvVars are all auto-prefixed with CRAFTENV_ -- you can add
// whatever you want here and access them via getenv() using the prefixed name
$craftEnvVars = array(
Expand All @@ -40,10 +42,10 @@
'DB_PASS' => 'REPLACE_ME',

// The site url to use; it can be hard-coded as well
'SITE_URL' => $protocol . $_SERVER['HTTP_HOST'] . '/',
'SITE_URL' => $protocol . $httpHost . '/',

// The base url environmentVariable to use for Assets; it can be hard-coded as well
'BASE_URL' => $protocol . $_SERVER['HTTP_HOST'] . '/',
'BASE_URL' => $protocol . $httpHost . '/',

// The base path environmentVariable for Assets; it can be hard-coded as well
'BASE_PATH' => realpath(dirname(__FILE__)) . '/public/',
Expand Down

0 comments on commit 462f4d0

Please sign in to comment.