LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-09-2006, 03:54 PM   #1
firemankurt
LQ Newbie
 
Registered: Jul 2006
Location: Ferndale WA USA
Distribution: MEPIS 6
Posts: 20

Rep: Reputation: 0
Question PHP file for configuring my application


I am working on several projects and I am distributing them on sourceforge.
I have a couple PHP files that hold settings for dropdown menus, user privleges, MySQL server settings and lots of other stuff.
The settings are like:

$UseType['A']['Description'] = "Administrator";
$UseType['A']['Access'] = "All";
$UseType['B']['Description'] = "List Manager";
$UseType['B']['Access'] = "0,1,2";

I want to come up with a way to allow other people to customize these settings without having to edit a PHP file.

What have other people done to acheive this?

If I had a plain text file like:


UseType A {
Description = Administrator
Access = All
}
UseType B {
Description = List Manager
Access = 0 1 2
}

How would I parse that into constants or variables for my scripts?
 
Old 08-09-2006, 04:19 PM   #2
silent_cutthroat
LQ Newbie
 
Registered: Nov 2005
Distribution: Arch
Posts: 27

Rep: Reputation: 15
You may use xml for configuration and parse it with the builtin facilities. If you don't want to write xml maybe the easiest way is to define a simple syntax and parse it with regular expressions. Also you can make small abstraction layer all over this and use different ways to store the configuration (simultaneously?), maybe even sql.
 
Old 08-09-2006, 09:03 PM   #3
firemankurt
LQ Newbie
 
Registered: Jul 2006
Location: Ferndale WA USA
Distribution: MEPIS 6
Posts: 20

Original Poster
Rep: Reputation: 0
What do you mean by "small abstraction layer"?
 
Old 08-10-2006, 12:42 AM   #4
firemankurt
LQ Newbie
 
Registered: Jul 2006
Location: Ferndale WA USA
Distribution: MEPIS 6
Posts: 20

Original Poster
Rep: Reputation: 0
I am interested in some examples if anyone has anything that they have done.

I started a script that edits the PHP file through an administration form but I hate to reinvent the wheel. There must be a standard way to do this.
 
Old 08-10-2006, 03:21 AM   #5
silent_cutthroat
LQ Newbie
 
Registered: Nov 2005
Distribution: Arch
Posts: 27

Rep: Reputation: 15
PHP5 offers some interesting features like overloading and the ArrayAccess interface. You can abstract your configuraton with them so everything looks like regular objects or arrays.

Code:
$someConfig = new XMLConfig('sample.conf');
echo $someConfig->attr0;
$someConfig->attr1 = 'blahblahblah';
$someConfig->update();
Or if you don't use php5:

Code:
$anotherConfig = new SQLConfig($sqllink);
echo $anotherConfig->getAttr('attr0');
$anotherConfig->setAttr('attr1', 'asdf');
$anotherConfig->update();
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP+MySQL application on a live CD cppansi Programming 1 05-16-2006 04:13 AM
PHP in application servers! subalan Linux - Software 1 07-17-2005 03:53 AM
PHP Application only POSTS maximum 200 items bigoxygen Linux - Software 3 04-15-2005 03:40 PM
PHP-nuke like application Smokey Linux - Software 2 07-20-2004 04:52 AM
start application openoffice through php on linux pradeepsamale Linux - Software 0 08-01-2003 06:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration