1. Go to this page and download the library: Download lefuturiste/localstorage 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/ */
lefuturiste / localstorage example snippets
imple key value store
$localStorage = new Lefuturiste\LocalStorage\LocalStorage();
$localStorage->set('my-key', 'my-value'); // set a value
$localStorage->set('my-key', ['object' => ['is_complex' => true, 'number' => 1]]); // all values are json encoded so you can save array with string, int, float, boolean and null values
$localStorage->save(); // this will write the file on disk, don't forget to call it when you mutate the state!
$localStorage->get('my-key'); // retrieve the value (this will decode the JSON)
$localStorage->has('my-key'); // will return true
$localStorage->has('unknown-key'); // will return false
$localStorage->del('my-key'); // yes it does what you think it will do
$localStorage->clear(); // you can remove all the keys using the clear() method
$localStorage->unlinkStorage(); // you can complety remove the .json file on the disk
// duration management
// by default all the keys are saved with the date of the creating, so you can if you want, delete all the keys olden than a specified duration.
$localStorage->deleteOlderThan(\Carbon\CarbonInterval::seconds(10));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.