Site config file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Site config file

Post by Todlerone »

Hello everyone and thank-you in advance for any help/suggestions. I have recently learned to code with OOP and have redone all of my function based code over to OOP. I have a much better grasp on the OOP way of programming and really enjoy it. The next thing I would like to do is setup a site config file that I can establish alot of my main variables. Should I make it a *.php file that you open once a year and edit or could/should it be placed in an MySQL table and allow for easier editing? Any help into the safest/best direction for this is very much appreciated.

CHEERS
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Site config file

Post by requinix »

I'd say to put it in a config file. If it gets used a lot and hardly ever changes then sticking it all in a database just means more overhead.
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Re: Site config file

Post by liljester »

IMO it depends on your preference. for me, if i want users to update the config, i put those settings in a database and create an interface to change them. if it is only settings that i will be editing, then sure a file is fine. however, i would never use a .php file for a file im including.. the only files that have php extensions are the ones that you intend to have execute, a setting file for me is typically an include (or require) file, and i save them with .inc extensions so they cannot be executed.
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Re: Site config file

Post by Todlerone »

TY to the both of you for your responses. The file I need only needs to be edited once a year at the beginning of the baseball year. Things like start of season, end of season, etc. Right now I make the changes in passed variables to the constructor in the class. I want to allow conveners to set this up themselves. The range of computer competent conveners scares me a little with editing a config file vs a database. Could editing a config file be made to be relatively simple and safe?

TY
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Re: Site config file

Post by liljester »

not really.. no.. they would have to be alble to somehow log into the server, find the correct file, open it in an editor of some sort, make the correct changes.. lol so i would say no. if you want non-programmers to make the changes just build a quick form that loads the current values into inputs from the database and stick a "save" button on the bottom of it.
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

Re: Site config file

Post by Todlerone »

Thanks for the response. I totally agree. Cheers
Post Reply