_ss_environment.php not being used in SS 3.7.3 framework


#1

Silverstripe Version:
3.7.3
Question:

I’m converting an app from SS 3.1.13 to 3.7.3 but can’t get the _ss_environment.php file to be used.
Guess I must be doing something wrong or there is a bug in 3.7.3
Any hints welcome :slight_smile:

Environment:
W10 1803 (latest patches), PowerShell_core 6.2.0, XAMPP 7.2.1

PS C:\SC_upgrade> php framework/cli-script.php "dev/build"

Please configure your database connection details.  You can do this by creating a file
called _ss_environment.php in either of the following locations:

 - C:\SC_upgrade\_ss_environment.php
 - C:\\_ss_environment.php


Put the following content into this file:
--------------------------------------------------
<?php

/* Change this from 'dev' to 'live' for a production environment. */
define('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>');

/* SSL support for MySQLPDODatabase */
/*
define('SS_DATABASE_CLASS', 'MySQLPDODatabase');
define('SS_DATABASE_SSL_KEY', '/path/to/keyfile');
define('SS_DATABASE_SSL_CERT', '/path/to/certfile');
define('SS_DATABASE_SSL_CA', '/path/to/cafile');;
*/
--------------------------------------------------

Once you have done that, run 'composer install' or './framework/sake dev/build' to create
an empty database.

For more information, please read this page in our docs:
http://docs.silverstripe.org/en/getting_started/environment_management/

PS C:\SC_upgrade> ls _ss_environment.php


    Directory: C:\SC_upgrade

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        03.05.2019    13:02            766 _ss_environment.php

PS C:\SC_upgrade> cat .\mysite\_config.php
<?php

global $project;
$project = 'mysite';
global $database;
$database = '(databasename)';

// Use _ss_environment.php file for configuration
require_once("conf/ConfigureFromEnv.php");

// replaces:
// global $databaseConfig;
// $databaseConfig = array(
        // "type" => 'MySQLDatabase',
        // "server" => 'localhost',
        // "username" => 'root',
        // "password" => '',
        // "database" => '',
        // "path" => '',
// );

// Set the site locale
i18n::set_locale('de_DE');
$allowed_locales = array(
                'de_DE' => 'German',
                'en_US' => 'English'
);
Config::inst()->remove('i18n', 'all_locales');
Config::inst()->update('i18n', 'all_locales', $allowed_locales);

Config::inst()->update('LeftAndMain', 'application_name', "Shopping Cart");
PS C:\SC_upgrade> composer info
burnbright/silverstripe-importexport     0.3.1   An upgrade to SilverStripe's bulk loading and exporting
composer/installers                      v1.6.0  A multi-framework Composer library installer
doctrine/instantiator                    1.0.5   A small, lightweight utility to instantiate objects in PHP with...
goodby/csv                               1.2.0   CSV import/export library
mustangostang/spyc                       0.6.2   A simple YAML loader/dumper class for PHP
myclabs/deep-copy                        1.7.0   Create deep copies (clones) of your objects
phpdocumentor/reflection-common          1.0.1   Common reflection classes used by phpdocumentor to reflect the ...
phpdocumentor/reflection-docblock        3.3.2   With this component, a library can provide support for annotati...
phpdocumentor/type-resolver              0.4.0
phpoffice/phpexcel                       1.8.2   PHPExcel - OpenXML - Read, Create and Write Spreadsheet documen...
phpspec/prophecy                         1.8.0   Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage                4.0.8   Library that provides collection, processing, and rendering fun...
phpunit/php-file-iterator                1.4.5   FilterIterator implementation that filters files based on a lis...
phpunit/php-text-template                1.2.1   Simple template engine.
phpunit/php-timer                        1.0.9   Utility class for timing
phpunit/php-token-stream                 1.4.12  Wrapper around PHP's tokenizer extension.
phpunit/phpunit                          5.7.27  The PHP Unit Testing framework.
phpunit/phpunit-mock-objects             3.4.4   Mock Object library for PHPUnit
praxisnetau/silverstripe-moderno-admin   1.1.4   A SilverStripe module to give the CMS a more modern, flat appea...
sebastian/code-unit-reverse-lookup       1.0.1   Looks up which function or method a line of code belongs to
sebastian/comparator                     1.2.4   Provides the functionality to compare PHP values for equality
sebastian/diff                           1.4.3   Diff implementation
sebastian/environment                    2.0.0   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                       2.0.0   Provides the functionality to export PHP variables for visualiz...
sebastian/global-state                   1.1.1   Snapshotting of global state
sebastian/object-enumerator              2.0.1   Traverses array structures and object graphs to enumerate all r...
sebastian/recursion-context              2.0.0   Provides functionality to recursively process PHP variables
sebastian/resource-operations            1.0.0   Provides a list of PHP built-in functions that operate on resou...
sebastian/version                        2.0.1   Library that helps with managing the version number of Git-host...
silverstripe-themes/simple               3.2.0   The SilverStripe simple theme (default SilverStripe 3 theme)
silverstripe/display-logic               1.7     Allows assignment of conditions for display and hide of specifi...
silverstripe/framework                   3.7.3   The SilverStripe framework
symbiote/silverstripe-datachange-tracker 4.0.7   Record and track changes to any dataobjects. View chages/diffs ...
symfony/polyfill-ctype                   v1.11.0 Symfony polyfill for ctype functions
symfony/yaml                             v3.4.27 Symfony Yaml Component
tractorcow/silverstripe-colorpicker      3.0.0   Color picker field for Silverstripe CMS using the ColorPicker j...
unclecheese/betterbuttons                1.3.14  Adds new form actions and buttons to GridField detail form for ...
webmozart/assert                         1.4.0   Assertions to validate method input/output with nice error mess...
PS C:\SC_upgrade>

#2

As suspected I had inherited an entry in _config.php that resulted in this strange behavior when converted to _ss_environment.php :frowning:

_config.php had:
// This is used by sake to know which directory points to which URL
global $_FILE_TO_URL_MAPPING;
// todo: eliminate hardcoded absolute path because it is a source of bugs!!!
$_FILE_TO_URL_MAPPING[‘C:\SC_upgrade’] = ‘http://localhost’;

but the absolute path was pointing to to wrong ‘old code’ dir in my case