PHP code example of irfantoor / datastore

1. Go to this page and download the library: Download irfantoor/datastore library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

irfantoor / datastore example snippets


$ds = new IrfanTOOR\Datastore('/yourpath/to/datatore/');

$ds = new IrfanTOOR\Datastore('/yourpath/to/datatore/');

if ($ds->has('hello')) {
	echo $ds->get('hello');
}

$ds->set('hello', 'Hello');
$ds->set('hello-world', 'Hello World!');
# ...

$meta = [
    'meta' => [
        'keywords' => 'hello, world',
        'author'   => 'Jhon Doe',
        # ...
    ];
];

$ds->setComponents('hello', 'Hello World!', $meta);

$info = $ds->info('hello-world');
print_r($info);

# Note: the information does not contain the value, which can be retrieved using
# the get function

$contents = $ds->get('hello', 'Hello');
echo $contents;
echo $ds->get('hello-world');

$ds->remove('hello');

$file = 'absolute\path\to\your\reference_file.txt';

$ds->addFile('reference', $file);

# or you can add some meta information
$ds->addFile('reference', $file, ['keywords' => 'reference', 'sites', 'index', '...']);