PHP code example of ivopetkov / object-storage
1. Go to this page and download the library: Download ivopetkov/object-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/ */
ivopetkov / object-storage example snippets
$storage = new \IvoPetkov\ObjectStorage('path/to/the/data/dir/');
// Save data
$storage->set([
'key' => 'books/1449392776',
'body' => 'book 1449392776 content in pdf format',
'metadata.title' => 'Programming PHP',
'metadata.authors' => '["Kevin Tatroe", "Peter MacIntyre", "Rasmus Lerdorf"]',
'metadata.year' => '2013'
]);
// Retrieve data
$result = $storage->get([
'key' => 'books/1449392776',
'result' => ['body', 'metadata.title']
]);
// Array
// (
// [body] => 'book 1449392776 content in pdf format'
// [metadata.title] => 'Programming PHP'
// )