PHP code example of lazier / storage

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

    

lazier / storage example snippets




use Lazier\Storage\Adapter\JsonFileStorage;
use Lazier\Storage\SimpleStorage;

$store = SimpleStorage::createWith(JsonFileStorage::create(__DIR__ . '/test.json'));
$store->clear();
$store->setItem('foo', 'bar');
$store->getItem('foo'); // returns "bar"
$store->removeItem('foo');
count($store); // 0



use Lazier\Storage\Adapter\EnvStorage;

$store = EnvStorage::create();

if ($store->getItem('APP_ENV') === 'dev') {
    echo 'Running in dev environment...' . PHP_EOL;
}