I have a script (a small and simple CMS-like system), which I'm always working on and use it for client sites. Since clients have different requirements, I've implemented a module system which allows me to modify/or add functionality to the CMS, without having to modify the CMS script.
How can I implement a configuration system that allows me to change the default settings of the main CMS from the modules?
For example the CMS has by default two menus: $menu = array('menu-1', 'menu-2');
How could I override this setting from the modules?
One solution I've thought of is to use constants and serialize/unserialize:
defined("BLA") or define("BLA", serialize(array(
'boo' => 'stuff',
'foo' => array('1', '2', '3'),
'moo' => true,
...
)));
So I could easily override this setting in the module initialization function which runs before the constant is defined in the CMS.
Then I'm using these constants everywhere inside my scripts, like:
$bla = unserialize(BLA);
...
foreach(unserialize(BLA) as $key => $value)...
Another alternative would be to use a global variable, but people say it's bad to use global.
So are there any better solutions to what I'm looking for?