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.

Installing SilverStripe

Getting SilverStripe up and running on your computer and on your web server.

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

Is there a specific test for live mode?


Reply

6 Posts   2194 Views

Avatar
ianpiper

19 January 2010 at 5:24am Community Member, 32 Posts

I have had an email from a colleague warning about a scam involving scallywags using SilverStripe sites that are in dev mode. From reading the documentation I think that my site is in live mode (the Director::set_environment_type("dev") directive is not set and it is not running on localhost). But is there a way that I can be sure? I do see some slightly alarming options when I look at the /dev/folder on my site, without authenticating as admin.

Reassurance craved!

Ian.
--

Avatar
Willr

19 January 2010 at 9:23am Forum Moderator, 5511 Posts

You can tell if your site is in live mode by logging out entirely then trying to do any of the developer tasks. Eg go to yoursite.com/dev/build. If it is in live mode you should be prompted for a password before you are allowed to rebuild the database. If you aren't asked for a password to do that you are either a) still logged in :) or b) not in live mode.

Or if you want to be a bit more certain you could add something like this in your _config file to just test it out (remove it afterwards)

die(Director::get_environment_type());

Which should give you a blank screen with either 'live', 'test', 'dev' or nothing.

Avatar
timcole

29 April 2010 at 1:30pm Community Member, 32 Posts

Hi - I have a site which is launching TODAY and I have just tried putting it in "Live" mode using: Director::set_environment_type("live"); in my _config.php.

But, I can still access /dev/build without being logged in! I tried putting your code in Willr and the pages came out saying "live". Any idea why it's still letting anyone at dev/build without needing a password?

Avatar
DsX

17 October 2010 at 6:29am Community Member, 178 Posts

I have a site, where I need to switch css resources depending on my dev mode.
How can I test my mode from within a template?

Avatar
Willr

17 October 2010 at 10:05am Forum Moderator, 5511 Posts

DsX - that function is not available in the templates but you can put something like this in page.php which will allow you to use <% if InDevMode %> (or you could look for live rather than dev)

function InDevMode() {
return (Director::isDev());
}

Avatar
DsX

17 October 2010 at 11:33am Community Member, 178 Posts

Thanks Willr,

thats just about the exact same as I added ;)
Might be a worthwhile one to add as a standard.