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?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
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?
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.
Thanks Willr - these are dev variables only to be used throughout the code in multiple places, and often differ in production and live enviornments.