Abstract: global configuration logics

    Date: 03/30/06 (PHP Development)    Keywords: php

    Hello everyone,

    This is not a question in particular, rather something I'd like to put up for discussion to hear different opinions from developers.

    Ok, I guess any medium/large scale script involves configurations, often those being stored in files. Some, mostly large scripts store conf settings in the DB, however this still requires for at least the DB configurations to be stored in a file.

    Now since global variables are a bit of an inconvenience in php, in my opinion of course, I've always had a problem with choosing the best way to store this kind of stuff. The problem being you cannot just create a $conf var somewhere in the application head and use it throughout the script, because you will have to declare it global whenever out of scope.

    Very many people use define() calls, however I believe that in the age of OOP doing this is somewhat clumsy and possibly wrong.

    What I personally do, is store my conf variables in a function which returns the whole array of configuration key/value pairs. Since functions in php are global this basically eliminates all inconveniences mentioned above. Still I find this method extremely artificial.

    I would like to hear how you approach this or similar issues, especially when dealing in an OOP envioronment.

    Source: http://community.livejournal.com/php_dev/67494.html

« More PHP Help || Mail Server Configuration »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home