PHP code example of typomedia / flatfile

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

    

typomedia / flatfile example snippets


use Typomedia\Flatfile\Flatfile;

$data = [
    'Moretti' => [
        'name' => 'Style Ale',
        'style' => 'European Amber Lager',
        'alcohol' => '9.1%'
    ]
];

$flatfile = new Flatfile('test.json');
$key = md5(serialize($data));

$flatfile->set((object)$data, $key);
$flatfile->get($key);
$flatfile->first();
$flatfile->last();
$flatfile->keys();
$flatfile->find('name', 'Style Ale');
$flatfile->delete($key);