PHP Class FileStorage

This class developed for simple implementation key-value storage in file system. It's written on PHP and very simple for using. Just to see examples of using.

It presents simple example of NoSQL database realised on PHP.

Store value into file fb.txt:
$f = new FileStorage(dirname(__FILE__).'/fb.txt');
$f->set($var_name, $var_value);
Read this value later:
$f = new FileStorage(dirname(__FILE__).'/fb.txt');
$value = $f->get($var_name);

I use dirname(__FILE__).'/fb.txt' for storing file near with class. It is a bad code, because you should save your data in private directory.

Please, be sure that current directory has writable fb.txt. Of course, you can provide any another filename for your strorage.

You can download or clone class FileStorage from the repository on GitHub.

git clone https://github.com/zoonman/filestorage.git

It is a good class for small datasets and I won't recommend you use this class when you'll have more than 1000 records.

If you want to tell me about bugs, please contact with me by e-mail.

January 5, 2012

Comments:

You can left first comment.

For commenting you should proceed to enter or register on the site.