PHP code example of tomkyle / repository-persistence
1. Go to this page and download the library: Download tomkyle/repository-persistence 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/ */
tomkyle / repository-persistence example snippets
use tomkyle\RepositoryPersistence\Repositories\Repository;
use tomkyle\RepositoryPersistence\Persistence;
$repo = new Repository(
new Persistence\JsonFilePersistence('path/to/json')
);
try {
$person = $repo->get('john-doe');
print_r($person);
}
catch (\OutOfBoundsException) {
// Not found
}
use tomkyle\RepositoryPersistence\Repositories;
use tomkyle\RepositoryPersistence\Persistence;
$persistence = new Persistence\JsonFilePersistence('path/to/json');
$persistence = new Persistence\YamlFilePersistence('path/to/yaml');
$persistence = new Persistence\FrontmatterFilePersistence(
new Persistence\JsonFilePersistence('path/to/json')
);
$persistence = new Persistence\PersistenceChain(
new Persistence\JsonFilePersistence('path/to/json'),
new Persistence\YamlFilePersistence('path/to/yaml')
);
$persistence = new Persistence\InMemoryPersistence();
$persistence = new Persistence\NoPersistence();
use tomkyle\RepositoryPersistence\Repositories\Repository;
use tomkyle\RepositoryPersistence\Persistence;
// Feed a persistence to the repo:
$persistence = new Persistence\InMemoryPersistence();
$repository = new Repository($persistence)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.