diff --git a/docs/en/04_Changelogs/4.0.0.md b/docs/en/04_Changelogs/4.0.0.md index f5e91e4b2..dd1648049 100644 --- a/docs/en/04_Changelogs/4.0.0.md +++ b/docs/en/04_Changelogs/4.0.0.md @@ -187,6 +187,72 @@ For a full list of renamed classes, check the `.upgrade.yml` definitions in each The rename won't affect class-based permission codes or database table names. +### `_ss_environment.php` changed to`.env` + +The php configuration `_ss_environment.php` file has been replaced in favour of a non-executable +`.env` file, which follows a syntax similar to an `.ini` file for key/value pair assignment. Like +the old php file, `.env` may be placed in either the web root, or one level above. + +For example, if you have the below `_ss_environment.php` file, your `.env` would be rewritten as follows: + +`_ss_environment.php`: + + +```php +// Environment +define('SS_ENVIRONMENT_TYPE', 'dev'); +define('SS_DEFAULT_ADMIN_USERNAME', 'admin'); +define('SS_DEFAULT_ADMIN_PASSWORD', 'password'); +$_FILE_TO_URL_MAPPING[__DIR__] = 'http://localhost'; + +// Database +define('SS_DATABASE_CHOOSE_NAME', true); +define('SS_DATABASE_CLASS', 'MySQLDatabase'); +define('SS_DATABASE_USERNAME', 'root'); +define('SS_DATABASE_PASSWORD', ''); +define('SS_DATABASE_SERVER', '127.0.0.1'); +``` + + +`.env`: + + +``` +## Environment +SS_ENVIRONMENT_TYPE="dev" +SS_DEFAULT_ADMIN_USERNAME="admin" +SS_DEFAULT_ADMIN_PASSWORD="password" +SS_BASE_URL="http://localhost/" + +### Database +SS_DATABASE_CHOOSE_NAME="true" +SS_DATABASE_CLASS="MySQLDatabase" +SS_DATABASE_USERNAME="root" +SS_DATABASE_PASSWORD="" +SS_DATABASE_SERVER="127.0.0.1" +``` + + +The removal of the `_ss_environment.php` file means that conditional logic is no longer available in the environment +variable set-up process. This generally encouraged bad practice and should be avoided. If you still require conditional +logic early in the bootstrap, this is best placed in the `_config.php` files. + +Note also that `$_FILE_TO_URL_MAPPING` has been removed and replaced with `SS_BASE_URL` env var. +This url must be an absolute url with an optional protocol. The following are valid, for example: + +``` +SS_BASE_URL="http://localhost/" +SS_BASE_URL="https://localhost/" +SS_BASE_URL="//localhost/" +``` + +The global values `$database` and `$databaseConfig` have been deprecated, as has `ConfigureFromEnv.php` +which is no longer necessary. + +To access environment variables you can use the `SilverStripe\Core\Environment::getEnv()` method. + +See [Environment Management docs](/getting-started/environment_management/) for full details. + ### Get upgrade tips on your code While there's some code we can automatically rewrite, other uses of changed SilverStripe APIs aren't that obvious. @@ -474,72 +540,6 @@ SilverStripe\Core\Manifest\ModuleManifest: project: mysite ``` -### `_ss_environment.php` changed to`.env` - -The php configuration `_ss_environment.php` file has been replaced in favour of a non-executable -`.env` file, which follows a syntax similar to an `.ini` file for key/value pair assignment. Like -the old php file, `.env` may be placed in either the web root, or one level above. - -For example, if you have the below `_ss_environment.php` file, your `.env` would be rewritten as follows: - -`_ss_environment.php`: - - -```php -// Environment -define('SS_ENVIRONMENT_TYPE', 'dev'); -define('SS_DEFAULT_ADMIN_USERNAME', 'admin'); -define('SS_DEFAULT_ADMIN_PASSWORD', 'password'); -$_FILE_TO_URL_MAPPING[__DIR__] = 'http://localhost'; - -// Database -define('SS_DATABASE_CHOOSE_NAME', true); -define('SS_DATABASE_CLASS', 'MySQLDatabase'); -define('SS_DATABASE_USERNAME', 'root'); -define('SS_DATABASE_PASSWORD', ''); -define('SS_DATABASE_SERVER', '127.0.0.1'); -``` - - -`.env`: - - -``` -## Environment -SS_ENVIRONMENT_TYPE="dev" -SS_DEFAULT_ADMIN_USERNAME="admin" -SS_DEFAULT_ADMIN_PASSWORD="password" -SS_BASE_URL="http://localhost/" - -### Database -SS_DATABASE_CHOOSE_NAME="true" -SS_DATABASE_CLASS="MySQLDatabase" -SS_DATABASE_USERNAME="root" -SS_DATABASE_PASSWORD="" -SS_DATABASE_SERVER="127.0.0.1" -``` - - -The removal of the `_ss_environment.php` file means that conditional logic is no longer available in the environment -variable set-up process. This generally encouraged bad practice and should be avoided. If you still require conditional -logic early in the bootstrap, this is best placed in the `_config.php` files. - -Note also that `$_FILE_TO_URL_MAPPING` has been removed and replaced with `SS_BASE_URL` env var. -This url must be an absolute url with an optional protocol. The following are valid, for example: - -``` -SS_BASE_URL="http://localhost/" -SS_BASE_URL="https://localhost/" -SS_BASE_URL="//localhost/" -``` - -The global values `$database` and `$databaseConfig` have been deprecated, as has `ConfigureFromEnv.php` -which is no longer necessary. - -To access environment variables you can use the `SilverStripe\Core\Environment::getEnv()` method. - -See [Environment Management docs](/getting-started/environment_management/) for full details. - ### Object class replaced by traits Object has been superseded by traits.