Skip to content

Commit

Permalink
Updating references to _ss_environment.php
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensby committed Nov 27, 2016
1 parent 43c2c11 commit 85f9a62
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 97 deletions.
17 changes: 7 additions & 10 deletions cli-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,20 @@
// Connect to database
if(!isset($databaseConfig) || !isset($databaseConfig['database']) || !$databaseConfig['database']) {
echo "\nPlease configure your database connection details. You can do this by creating a file
called _ss_environment.php in either of the following locations:\n\n";
echo " - " . BASE_PATH . DIRECTORY_SEPARATOR . "_ss_environment.php\n - ";
echo dirname(BASE_PATH) . DIRECTORY_SEPARATOR . "_ss_environment.php\n\n";
called .env in " . BASE_PATH;
echo <<<ENVCONTENT
Put the following content into this file:
--------------------------------------------------
<?php
/* Change this from 'dev' to 'live' for a production environment. */
define('SS_ENVIRONMENT_TYPE', 'dev');
# Change this from 'dev' to 'live' for a production environment.
SS_ENVIRONMENT_TYPE="dev"
/* This defines a default database user */
define('SS_DATABASE_SERVER', 'localhost');
define('SS_DATABASE_USERNAME', '<user>');
define('SS_DATABASE_PASSWORD', '<password>');
define('SS_DATABASE_NAME', '<database>');
SS_DATABASE_SERVER="localhost"
SS_DATABASE_USERNAME="<user>"
SS_DATABASE_PASSWORD="<password>"
SS_DATABASE_NAME="<database>"
--------------------------------------------------
Once you have done that, run 'composer install' or './framework/sake dev/build' to create
Expand Down
2 changes: 1 addition & 1 deletion docs/en/00_Getting_Started/01_Installation/03_Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $ composer create-project silverstripe/installer ./silverstripe
* Rename the unpacked directory from `C:\wamp\www\silverstripe-vX.X.X` to `C:\wamp\www\silverstripe`

## Install and configure
* Option 1: Environment file - Set up a file named _ss_environment.php either in the webroot or a directory above webroot and setup as per the [Environment Management process](/getting_started/environment_management).
* Option 1: Environment file - Set up a file named `.env` file either in the webroot and setup as per the [Environment Management process](/getting_started/environment_management).

* Option 2: Installer - Visit `http://localhost/silverstripe` - you will see SilverStripe's installation screen.
* You should be able to click "Install SilverStripe" and the installer will do its thing. It takes a minute or two.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,21 @@ You will need to give **Modify** permission to **IUSR** user. To do it right cli

Now that we've got the backend server software sorted out, it's time to install the SilverStripe CMS/framework.

Create a new file called **_ss_environment.php** in **C:\inetpub\wwwroot**
Create a new file called `.env` in **C:\inetpub\wwwroot\ss**

This file tells SilverStripe projects installed on this machine which database server and credentials, as well as anything environment specific.

Inside the newly created _ss_environment.php file, insert the following code:
Inside the newly created `.env` file, insert the following code:

<?php
/* What kind of environment is this: development, test, or live (ie, production)? */
define('SS_ENVIRONMENT_TYPE', 'dev');
/* Database connection */
define('SS_DATABASE_SERVER', 'localhost');
define('SS_DATABASE_USERNAME', 'sa');
define('SS_DATABASE_PASSWORD', '');
/* Configure a default username and password to access the CMS on all sites in this environment */
define('SS_DEFAULT_ADMIN_USERNAME', 'username');
define('SS_DEFAULT_ADMIN_PASSWORD', 'password');
# What kind of environment is this: development, test, or live (ie, production)?
SS_ENVIRONMENT_TYPE="dev";
# Database connection
SS_DATABASE_SERVER="localhost"
SS_DATABASE_USERNAME="sa"
SS_DATABASE_PASSWORD=""
# Configure a default username and password to access the CMS on all sites in this environment
SS_DEFAULT_ADMIN_USERNAME="username"
SS_DEFAULT_ADMIN_PASSWORD="password"

Insert the password you created for SQL Server earlier into the **SS_DATABASE_PASSWORD** field that is currently empty.

Expand Down Expand Up @@ -211,7 +210,7 @@ If all goes to plan, you're done, and you should see a basic template with a few

Most of the time, it's caused by a loaded PHP extension that is broken.

* Have you set up the MSSQL database details correctly in _ss_environment.php?
* Have you set up the MSSQL database details correctly in `.env` file?
* Have you made IIS expose errors? (see "How do I make IIS expose errors..." below)
* Are you running non-standard PHP extensions? If so, try unloading them one by one
* Make sure you're using the latest [[http://www.microsoft.com/downloads/en/details.aspx?FamilyID=80E44913-24B4-4113-8807-CAAE6CF2CA05&displaylang=en/|Microsoft Drivers for PHP for SQL Server]]
Expand Down
2 changes: 1 addition & 1 deletion docs/en/00_Getting_Started/02_Composer.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Since SilverStripe modules are installed into their own folder, you have to mana
Here is the default SilverStripe [.gitignore](http://git-scm.com/docs/gitignore) with the forum module ignored

assets/*
_ss_environment.php
.env
tools/phing-metadata
silverstripe-cache
.buildpath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ summary: Site configuration variables such as database connection details, envir
# Environment Variables

Environment specific variables like database connection details, API keys and other server configuration should be kept
outside the application code in a separate `_ss_environment.php` file. This file is stored outside the web root and
version control for security reasons.
outside the application code in a separate `.env` file. This file is stored in the web root and
kept out of version control for security reasons.

For more information on the environment file, see the [Environment Management](../../getting_started/environment_management/)
documentation.
For more information see our docs on [Environment Management](../../getting_started/environment_management/).

Data which isn't sensitive that can be in version control but is mostly static such as constants is best suited to be
included through the [Configuration API](configuration) based on the standard environment types (dev / test / live).
included through the [Configuration API](configuration) based on the standard environment types (dev / test / live).
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ The definition of setting an environment type in a `mysite/_config/app.yml` look
Director:
environment_type: 'dev'

The definition of setting an environment type in a `_ss_environment.php` file looks like
The definition of setting an environment type in a `.env` file looks like

:::php
define('SS_ENVIRONMENT_TYPE', 'dev');
SS_ENVIRONMENT_TYPE="dev"

The three environment types you can set are `dev`, `test` and `live`.

Expand Down
11 changes: 5 additions & 6 deletions docs/en/02_Developer_Guides/09_Security/03_Authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ When a new SilverStripe site is created for the first time, it may be necessary
CMS access for the first time. SilverStripe provides a default admin configuration system, which allows a username
and password to be configured for a single special user outside of the normal membership system.

It is advisable to configure this user in your `_ss_environment.php` file outside of the web root, as below:
It is advisable to configure this user in your `.env` file inside of the web root, as below:

:::php
// Configure a default username and password to access the CMS on all sites in this environment.
define('SS_DEFAULT_ADMIN_USERNAME', 'admin');
define('SS_DEFAULT_ADMIN_PASSWORD', 'password');
# Configure a default username and password to access the CMS on all sites in this environment.
SS_DEFAULT_ADMIN_USERNAME="admin"
SS_DEFAULT_ADMIN_PASSWORD="password"

When a user logs in with these credentials, then a [api:Member] with the Email 'admin' will be generated in
the database, but without any password information. This means that the password can be reset or changed by simply
updating the `_ss_environment.php` file.
updating the `.env` file.
23 changes: 10 additions & 13 deletions docs/en/02_Developer_Guides/09_Security/04_Secure_Coding.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,10 @@ as well as the login form.

To prevent a forged hostname appearing being used by the application, SilverStripe
allows the configure of a whitelist of hosts that are allowed to access the system. By defining
this whitelist in your _ss_environment.php file, any request presenting a `Host` header that is
this whitelist in your `.env` file, any request presenting a `Host` header that is
_not_ in this list will be blocked with a HTTP 400 error:

:::php
define('SS_ALLOWED_HOSTS', 'www.mysite.com,mysite.com,subdomain.mysite.com');
SS_ALLOWED_HOSTS="www.mysite.com,mysite.com,subdomain.mysite.com"

Please note that if this configuration is defined, you _must_ include _all_ subdomains (eg www.)
that will be accessing the site.
Expand All @@ -556,37 +555,35 @@ mechanisms, as rewritten urls could persist between requests in order to misdire
into visiting external sites.

In order to prevent this kind of attack, it's necessary to whitelist trusted proxy
server IPs using the SS_TRUSTED_PROXY_IPS define in your _ss_environment.php.

server IPs using the SS_TRUSTED_PROXY_IPS define in your `.env`.

:::php
define('SS_TRUSTED_PROXY_IPS', '127.0.0.1,192.168.0.1');
define('SS_TRUSTED_PROXY_HOST_HEADER', 'HTTP_X_FORWARDED_HOST');
define('SS_TRUSTED_PROXY_IP_HEADER', 'HTTP_X_FORWARDED_FOR');
define('SS_TRUSTED_PROXY_PROTOCOL_HEADER', 'HTTP_X_FORWARDED_PROTOCOL');
SS_TRUSTED_PROXY_IPS="127.0.0.1,192.168.0.1"
SS_TRUSTED_PROXY_HOST_HEADER="HTTP_X_FORWARDED_HOST"
SS_TRUSTED_PROXY_IP_HEADER="HTTP_X_FORWARDED_FOR"
SS_TRUSTED_PROXY_PROTOCOL_HEADER="HTTP_X_FORWARDED_PROTOCOL"

At the same time, you'll also need to define which headers you trust from these proxy IPs. Since there are multiple ways through which proxies can pass through HTTP information on the original hostname, IP and protocol, these values need to be adjusted for your specific proxy. The header names match their equivalent `$_SERVER` values.

If there is no proxy server, 'none' can be used to distrust all clients.
If only trusted servers will make requests then you can use '*' to trust all clients.
Otherwise a comma separated list of individual IP addresses should be declared.

This behaviour is enabled whenever SS_TRUSTED_PROXY_IPS is defined, or if the
This behaviour is enabled whenever `SS_TRUSTED_PROXY_IPS` is defined, or if the
`BlockUntrustedIPs` environment variable is declared. It is advisable to include the
following in your .htaccess to ensure this behaviour is activated.


<IfModule mod_env.c>
# Ensure that X-Forwarded-Host is only allowed to determine the request
# hostname for servers ips defined by SS_TRUSTED_PROXY_IPS in your _ss_environment.php
# hostname for servers ips defined by SS_TRUSTED_PROXY_IPS in your .env
# Note that in a future release this setting will be always on.
SetEnv BlockUntrustedIPs true
</IfModule>


In a future release this behaviour will be changed to be on by default, and this environment
variable will be no longer necessary, thus it will be necessary to always set
SS_TRUSTED_PROXY_IPS if using a proxy.
`SS_TRUSTED_PROXY_IPS` if using a proxy.

## Related

Expand Down
2 changes: 1 addition & 1 deletion docs/en/02_Developer_Guides/10_Email/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ assets folder instead.
A bounce handler email can be specified one of a few ways:

* Via config by setting the `Mailer.default_bounce_email` config to the desired email address.
* Via _ss_environment.php by setting the `BOUNCE_EMAIL` definition.
* Via defining a constant `BOUNCE_EMAIL`.
* Via PHP by calling `Email::mailer()->setBounceEmail('[email protected]');`

## API Documentation
Expand Down
5 changes: 2 additions & 3 deletions docs/en/02_Developer_Guides/14_Files/03_File_Security.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,10 @@ In order to better ensure these files are protected, it's recommended to move th
root altogether.

For instance, given your web root is in the folder `/sites/mysite/www`, you can tell the asset store
to put protected files into `/sites/mysite/protected` with the below `_ss_environment.php` setting:
to put protected files into `/sites/mysite/protected` with the below `.env` setting:


:::php
define('SS_PROTECTED_ASSETS_PATH', '/sites/mysite/protected');
SS_PROTECTED_ASSETS_PATH="/sites/mysite/protected"


### Configuring: File types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ By default, manifests are stored on the local filesystem through PHP's `serializ
Combined with PHP opcode caching this provides fast access.
In order to share manifests between servers, or centralise cache management,
other storage adapters are available. These can be configured by a `SS_MANIFESTCACHE` constant,
placed in your `_ss_environment.php`.
placed in your `.env`.

* `ManifestCache_File`: The default adapter using PHP's `serialize()`
* `ManifestCache_File_PHP`: Using `var_export()`, which is faster when a PHP opcode cache is installed
Expand Down
7 changes: 3 additions & 4 deletions docs/en/02_Developer_Guides/16_Execution_Pipeline/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,12 @@ can leave sensitive files exposed to public access (the `RewriteRule` conditions

All requests go through `framework/main.php`, which sets up the execution environment:

* Tries to locate an `_ss_environment.php`
[configuration file](/getting_started/environment_management) in the webroot,
or the two levels above it (to allow sharing configuration between multiple webroots).
* Tries to locate an `.env`
[configuration file](/getting_started/environment_management) in the webroot.
* Sets constants based on the filesystem structure (e.g. `BASE_URL`, `BASE_PATH` and `TEMP_FOLDER`)
* Normalizes the `url` parameter in preparation for handing it off to `Director`
* Connects to a database, based on information stored in the global `$databaseConfig` variable.
The configuration is either defined in your `_config.php`, or through `_ss_environment.php`
The configuration is either defined in your `_config.php`, or through `.env`
* Sets up [error handlers](../debugging/error_handling)
* Optionally continues a [session](../cookies_and_sessions/sessions) if the request already contains a session identifier
* Loads manifests for PHP classes, templates, as well as any [YAML configuration](../configuration).
Expand Down
7 changes: 3 additions & 4 deletions docs/en/05_Contributing/04_Release_Process.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ This change could be committed to a minor release like *3.2.0*, and remains depr
(e.g. *3.3.0*, *3.4.0*), until a new major release (e.g. *4.0.0*), at which point it gets removed from the codebase.

Deprecation notices are enabled by default on dev environment, but can be
turned off via either _ss_environment.php or in your _config.php. Deprecation
turned off via either `.env` or in your _config.php. Deprecation
notices are always disabled on both live and test.


Expand All @@ -90,11 +90,10 @@ notices are always disabled on both live and test.
Deprecation::set_enabled(false);


`_ss_environment.php`
`.env`


:::php
define('SS_DEPRECATION_ENABLED', false);
SS_DEPRECATION_ENABLED="0"


## Security Releases
Expand Down
36 changes: 17 additions & 19 deletions docs/en/05_Contributing/05_Making_A_SilverStripe_Core_Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,28 @@ As a core contributor it is necessary to have installed the following set of too
* [AWS CLI tools](https://aws.amazon.com/cli/):
- `pip install awscli`
* The `tar` and `zip` commands
* A good _ss_environment.php setup in your localhost webroot.
* A good `.env` setup in your localhost webroot.

Example `_ss_environment.php`:
Example `.env`:

:::php
<?php
// Environent
define('SS_TRUSTED_PROXY_IPS', '*');
define('SS_ENVIRONMENT_TYPE', 'dev');
# Environent
SS_TRUSTED_PROXY_IPS="*"
SS_ENVIRONMENT_TYPE="dev"

// DB Credentials
define('SS_DATABASE_CLASS', 'MySQLDatabase');
define('SS_DATABASE_SERVER', '127.0.0.1');
define('SS_DATABASE_USERNAME', 'root');
define('SS_DATABASE_PASSWORD', '');
# DB Credentials
SS_DATABASE_CLASS="MySQLDatabase"
SS_DATABASE_SERVER="127.0.0.1"
SS_DATABASE_USERNAME="root"
SS_DATABASE_PASSWORD=""

// Each release will have its own DB
define('SS_DATABASE_CHOOSE_NAME', true);
# Each release will have its own DB
SS_DATABASE_CHOOSE_NAME="ru"

// So you can test releases
define('SS_DEFAULT_ADMIN_USERNAME', 'admin');
define('SS_DEFAULT_ADMIN_PASSWORD', 'password');
# So you can test releases
SS_DEFAULT_ADMIN_USERNAME="admin"
SS_DEFAULT_ADMIN_PASSWORD="password"

// Basic CLI hostname
# Basic CLI hostname
global $_FILE_TO_URL_MAPPING;
$_FILE_TO_URL_MAPPING[__DIR__] = "http://localhost";

Expand Down Expand Up @@ -203,7 +201,7 @@ and needs to be manually advanced):
back up to transifex to make them available for translation. Changes to these
files will also be automatically committed to git.
* `release:test` Will run all unit tests on this release. Make sure that you
setup your `_ss_environment.php` correctly (as above) so that this will work.
setup your `.env` correctly (as above) so that this will work.
* `release:changelog` Will compare the current branch head with `--from` parameter
version in order to generate a changelog file. This wil be placed into the
`./framework/docs/en/04_Changelogs/` folder. If an existing file named after
Expand Down
3 changes: 1 addition & 2 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
*
* The main.php does a number of set-up activities for the request.
*
* - Includes the first one of the following files that it finds: (root)/_ss_environment.php,
* (root)/../_ss_environment.php, or (root)/../../_ss_environment.php
* - Includes the .env file in your webroot
* - Gets an up-to-date manifest from {@link ManifestBuilder}
* - Sets up error handlers with {@link Debug::loadErrorHandlers()}
* - Calls {@link DB::connect()}, passing it the global variable $databaseConfig that should
Expand Down
4 changes: 2 additions & 2 deletions src/Control/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Email extends ViewableData {
* It will also add " [addressed to (email), cc to (email), bcc to (email)]" to the end of the subject line
*
* To set this, set Email.send_all_emails_to in your yml config file.
* It can also be set in _ss_environment.php with SS_SEND_ALL_EMAILS_TO.
* It can also be set in .env with SS_SEND_ALL_EMAILS_TO.
*
* @config
* @var string $send_all_emails_to Email-Address
Expand All @@ -121,7 +121,7 @@ class Email extends ViewableData {
* It will also add " [, from to (email)]" to the end of the subject line
*
* To set this, set Email.send_all_emails_from in your yml config file.
* It can also be set in _ss_environment.php with SS_SEND_ALL_EMAILS_FROM.
* It can also be set in .env with SS_SEND_ALL_EMAILS_FROM.
*
* @config
* @var string $send_all_emails_from Email-Address
Expand Down
1 change: 0 additions & 1 deletion src/Core/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* This file is the Framework constants bootstrap. It will prepare some basic common constants.
*
* It takes care of:
* - Including _ss_environment.php
* - Normalisation of $_SERVER values
* - Initialisation of necessary constants (mostly paths)
*
Expand Down
2 changes: 1 addition & 1 deletion src/Dev/Install/client/dist/js/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $(document).ready(function() {

/**
* Toggle field readonly modes, if check configuration comes from
* _ss_environment (values populated on reload).
* environment variables (values populated on reload).
*/
$('#use_environment').click(function(e) {
if(!$(this).is(':checked')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Dev/Install/config-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ <h3 class="sectionHeading">Database Configuration <small>Step 2 of 5</small></h3
<?php if($envFileExists) { ?>
<div id="use_environment_field" class="field">
<input id="use_environment" type="checkbox" name="useEnv" <?php if($usingEnv) echo "checked=\"checked\"" ?>>
<label for="use_environment">Use _ss_environment file for configuration (<a href="http://doc.silverstripe.org/framework/en/topics/environment-management" target="_blank">?</a>)</label>
<label for="use_environment">Use environment variables for configuration (<a href="http://doc.silverstripe.org/framework/en/topics/environment-management" target="_blank">?</a>)</label>
</div>
<?php } ?>

Expand Down
2 changes: 1 addition & 1 deletion src/Dev/Install/install.php5
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ class Installer extends InstallRequirements {
// Write the config file
global $usingEnv;
if($usingEnv) {
$this->statusMessage("Setting up 'mysite/_config.php' for use with _ss_environment.php...");
$this->statusMessage("Setting up 'mysite/_config.php' for use with environment variables...");
$this->writeToFile("mysite/_config.php", <<<PHP
<?php
Expand Down
Loading

0 comments on commit 85f9a62

Please sign in to comment.