English 中文(简体)
A design suggestion for changing php or general server side code through a web console
原标题:

Ok so this is my situation...a web application in PHP uses a "config" file for various parameters. This config file is nothing but a php file, say config.php with a global array of the form

$config[ param_name ] =  param_value ;
$config[ param_name2 ] =  param_value2 ;

Now I am currently writing an admin app that I want to use to control the main app. One of the things I want the admin app to be able to do is change the config values. So my use case will be something like change the value through an html form element and it should change the config.php replacing the value of the corresponding array index.

This is obviously not specific to php; but I d love to hear some ideas on how one would go about editing this file. Any ideas?

Thanks!

问题回答

I have another suggestion: have the configuration parameters sit in a database. Have your admin console work on the database instead.

If you are worried about performance, use APC to cache the parameters.

This way, you can add this configuration database to your other database backup procedure you have already in place.

I would suggest moving all configurable options out of the PHP file and into an external storage (INI file, database, xml, anything). Then you can initialize all the variables you read from the external file in your application s bootstrap file

Another option is to modify the PHP configuration file so it reads its information from an easy-to-access format like YAML.

That way the config file could be accessed by just about any language. A good alternative if you don t want yo use a database.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签