Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Lithium's equivalent to CakePHP's Configure::load() and Configure::read()?

Tags:

lithium

I'd like to store configuration data in separate files and load it/read it using the proper Lithium way.

like image 1000
Aaron Shafovaloff Avatar asked Oct 18 '10 20:10

Aaron Shafovaloff


1 Answers

Depends on what it's for. We pretty strongly discourage throwing around global configuration unless it's managed carefully.

If it's related to connecting to some kind of external system, I'd suggest you take a look at the Connections, Cache, Session, Auth or Logger classes. Take a look here for more info: http://li3.me/docs/lithium/core/Adaptable

If your configuration doesn't fall into any specific categor(y/ies), and is related to general site operations, take a look at the Environment class: http://li3.me/docs/lithium/core/Environment. It doesn't have any specific methods to load from files, but it just works with arrays, so if you have a config file that returns an array, you can pass it the value of include "foo.php" as a parameter.

If you go this route though, be sure that you carefully manage your configuration and don't change it once you've written it. Poor management of this kind of global state is the #1 cause of software bugs.

like image 146
Nate Abele Avatar answered Dec 21 '22 22:12

Nate Abele