21294 Posts in 5734 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1243 Views |
-
Managing environments

19 October 2009 at 7:40am Last edited: 19 October 2009 7:42am
How could I achieve this: A (set of) configuration that "knows" whether this is development or live? I want to maintain my configs without worrying about which file to upload where or overwriting essential things. I tried the code below in my mysite/_config.php, but this does not work. Any ideas? Thanks!
Director::set_dev_servers(array(
'localhost',
'127.0.0.1',
));if(Director::isDev()){
global $databaseConfig;
$databaseConfig = array(
"type" => "MySQLDatabase",
"server" => "localhost",
"username" => "root",
"password" => "",
"database" => "qu",
);
Security::setDefaultAdmin('bla@fasel.com', '4711');
} else { /* Live */
global $databaseConfig;
$databaseConfig = array(
"type" => "MySQLDatabase",
"server" => "mysql9-03",
"username" => "qiolanned",
"password" => "RcC)xnF6n",
"database" => "qiolanned",
);
Debug::send_errors_to("bla@fasel.com");
} -
Re: Managing environments

19 October 2009 at 8:10am
Is this what you're looking for? http://doc.silverstripe.com/doku.php?id=environment-management
-
Re: Managing environments

19 October 2009 at 9:17am
Thanks, socks. Not entirely. I have seen this docs, but it only describes how I can spread basic credentials over different developments. I want two set of credentials for the same site. Unless I have overlooked something, the solution is not there.
-
Re: Managing environments

19 October 2009 at 9:27am
Socks was on the correct track - if I understand correctly you want dev / live versions of your config file. This is where _ss_environment.php comes into play. You have that file on each of your servers above the web root to define the global states eg like db details.
Things like mysql user, and server go in there as these are usually the same over multiple sites on your host. If you have project specific dev / live differences then you would use a Director::isDev() in the _config of the project usually you have to do this for api keys.
-
Re: Managing environments

19 October 2009 at 9:45am
Thanks, but sorry: I don't get that. I wanted to use Director:isDev() and it didn't work. This is why I have posted parts of the _config.php
Unless I misunderstand the obvious, _ss_environment is fine if you have almost identical setting for a number of sites on _one_ server. I have _one_ site on _two_ servers, and I want 1 config file that knows which parts to pick from.
isDev() would be fine - please cf. my excerpt (which didn't work for me).
-
Re: Managing environments

19 October 2009 at 9:54am
In your individual _ss_environments (on your dev / live machines) make sure you have set the environment type to dev on your dev box define('SS_ENVIRONMENT_TYPE', 'dev'); and define live on your live site define('SS_ENVIRONMENT_TYPE', 'live'); Once you have set that in your _ss_environment file you can then your code statement should work fine
Even though you have defined Director::set_dev_servers() which should work I prefer to be safe and define the environment type.
| 1243 Views | ||
|
Page:
1
|
Go to Top |



