What is the best way to save config variables in a PHP web app?

Graphixx

New Member
I often switch between .NET and PHP development. With ASP.NET sites I save configuration information (e.g. connection strings, directories, application setting) in the web.config file which is appropriately protected and easy to access the values, etc.In PHP, I solve this with a class that has static methods for each variable:\[code\]class webconfig { public static function defaultPageIdCode() { return 'welcome'; }}\[/code\]The file is included by the app variables are accessed with a one-line:\[code\]$dp = webconfig::defaultPageIdCode();\[/code\]And since PHP isn't compiled, it is easy to telnet in and change a value for a website anyway, so this solution works fairly well and gives me these two advantages:
  • I can add logic to a config variable without breaking its interface with the application
  • these config variables appear as intellisense in my e.g. Eclipse, NetBeans, etc.
But I can imagine there are other ways people solve saving web config settings in PHP which may have other advantages.Especially those who have experience with a number of PHP frameworks, what are other ways of saving config variables and their advantages and disadvantages?
 
Back
Top