Hi everybody

This post is not so much a question to solve a problem but more in the direction: what would you do and why.

I'm starting a new project and is preparing the basic layout for the application. In all my previous projects I have had a config file that all other files would require where I used 'define' to specify database connection parameters, site root, picture root and stuff like that.

This works without problems, but as I have started to code more in a OO way, I was wondering if it would not me bore clean to create a site class with constants for all these values so instead of doing:

echo '<a href=”' . ROOT . '”>Go home</a>';

I would do this:

echo '<a href=”' .  Site::ROOT . '”>Go home</a>';

The second might be more verbose in this case, but for a lot of values, being able to associate them with the site could prove quite valuable if you or someone else has to look at the code half a year from when it was original written.

The verbose issue aside, having a config file separate from the actual code seems intuitively more clean (in my mind at least) and using a class for storing config values might no be the best of ideas. But the site class could be build from the config file either each time a script was requested or as part of the build process when your application is deployed to the server.

Either way... both solutions would work.... what I'm looking for here is maybe some comments to the ideas before I go ahead with one of them.

Joe

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to