Jump to:

23575 Posts in 19402 Topics by 2893 members

General Questions

SilverStripe Forums » General Questions » Managing environments

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1463 Views
  • Skipper
    Avatar
    Community Member
    16 Posts

    Managing environments Link to this post

    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");
    }

  • socks
    Avatar
    Community Member
    190 Posts

    Re: Managing environments Link to this post

  • Skipper
    Avatar
    Community Member
    16 Posts

    Re: Managing environments Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: Managing environments Link to this post

    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.

  • Skipper
    Avatar
    Community Member
    16 Posts

    Re: Managing environments Link to this post

    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).

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: Managing environments Link to this post

    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.

    1463 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.