Jan 09, 2019

PHP allows serialization, which is cool, but how do you store and use this data? Sure, you could use databases (SQL, et al.), but what if you don't want to deal with DBs just to store a few objects?

A few months ago, I wrote varDx, a tiny library (~2KB, <100 lines) which solves this problem. It allows you to read/write objects to/from flat files easily.

Usage is as simple as this:

require 'varDx.php';

$dx = new \varDx\cDX; //create an object
$dx->def('file.dat'); //define data file

$val1 = "this is a string";

$dx->write('str1', $val1); //writes key to file
echo $dx->read('data1'); //returns key value from file

It has functions for reading, writing, modifying, checking and deleting data. Get the code from the Github repository, and see the README file for more documentation.