Joshwaa
Joshwaa

Reputation: 840

Storing Configuration without MySQL

I want to be able to store website configuration without the use of mysql. I also want the user to be able to change this information from a web page. What's the best methods to do so?

Upvotes: 0

Views: 502

Answers (4)

Jay Sidri
Jay Sidri

Reputation: 6406

I would use a .ini file format to store configuration. It's human readable in its raw format and fairly easy to parse via PHP (parse_ini_file). A point to note here is that PHP (strangely) doesn't support writing to ini files natively, but if you look at the manual page for parse_ini_file you can find an user submitted example of how do it.

Altough I have not used in PHP projects, YAML (Yet Another Markup Language) seems like a good format to store configuration info (it's pretty much the default config format for rails projects). You can use the syck pecl library to easily read and write stuff in the YAML format

Upvotes: 2

glowworms
glowworms

Reputation: 410

You could try cloud based databases if you don't have access to store data on your own server.

Upvotes: 1

Tak
Tak

Reputation: 11732

Storing a file is the easiest option. You could store it in plain text, XML, JSON, etc. You might want to try an ini file which can be read/written by PHP - in which case this answer should help.

Upvotes: 2

BenMorel
BenMorel

Reputation: 36632

Valuable options are a SQLite database, or just a PHP file containing a serialized array if you want a really simple option:

// reading configuration
$config = unserialize(file_get_contents('config'));

// storing configuration
file_put_contents('config', serialize($config));

Upvotes: 4

Related Questions