Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Environments


Go to End


2 Posts   2109 Views

Avatar
Ingo

Forum Moderator, 801 Posts

1 May 2007 at 3:24pm

hey guys,

i've just started using SS on my local machine, and have some problems how to write my _config.php. currently, we do some custom code for switching between configs, based on path, e.g. "if dir==/ischommer".

however:
- switches for my local environment shouldn't appear in _config.php (might collide with other local dev-environments)
- not everybody wants their local database-passwords flying around in svn
- you still might want some code shared between configs
- in more complicated scenarios, we might need more than one _config.php (e.g. for NZCT I had two different _config.php for the server at their offices and manu)

has anybody already put some thought into formalizing this - or has come up with some best-practices? while most of the stuff can be achieved by custom if/switch-statements in the _config.php, it would be nice to have some kind of "environment-switcher" that is able to handle different configurations, triggered by flags which are not under SVN.

Avatar
Sam

Administrator, 690 Posts

2 May 2007 at 8:59pm

Edited: 02/05/2007 11:10pm

I haven't done anything myself, but here's an idea:

If you have a folder ~/Sites, with subfolders for each of your projects.

Make ~/Sites/_env_config.php:

<?php

$databaseConfig['username'] = 'XXX';
$databaseConfig['password'] = 'XXX';

Director::set_environment_type("dev");
Debug::sendLiveErrorsTo("yourname@silverstripe.com");

// etc

?>

Then, in your application's _config.php you could have something like:

if(file_exists("../../_env_config.php")) include("../../_env_config.php");

Put it in after databaseConfig is defined, so that the u/p can be overridden properly.