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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

Best way to set config variables


Go to End


3 Posts   1494 Views

Avatar
pingu

Community Member, 75 Posts

15 July 2010 at 2:02pm

What's the best way to set variables in your config file that can be used throughout your app?

Currently I'm using a series of define statements:
define('CUSTOMERGROUP',8);
...

Is there a better way, or what other practices do you guys recommend?

Avatar
Willr

Forum Moderator, 5523 Posts

15 July 2010 at 7:11pm

Are these values going to be editable by the user at any point? If they are then SiteConfig is a good place to add then. For code (devs only) I do as like you with define() statements.

Avatar
pingu

Community Member, 75 Posts

15 July 2010 at 10:22pm

Edited: 15/07/2010 10:22pm

Thanks Willr - these are dev variables only to be used throughout the code in multiple places, and often differ in production and live enviornments.