PHP code example of sensorario / php-store

1. Go to this page and download the library: Download sensorario/php-store 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/ */

    

sensorario / php-store example snippets


use Memory\Config\Config;
use Memory\Services\Memory;
use Memory\Services\Persist;
use Memory\Persistor\FileSystemPersistor;
use Memory\Storage;

class Store
{
    private $storage;

    public function __construct()
    {
        $config = new Config([
            'path' => __DIR__ . '/../../../../var/data/store',
        ]);

        $memory = new Memory();
        $memory->init($config);
        $memory->loadFromFileSystem();

        $this->storage = new Storage(
            $memory,
            new Persist(
                new FileSystemPersistor(),
                $config
            ),
            $config
        );
    }

    public function getStorage()
    {
        return $this->storage;
    }
}