PHP code example of everzet / persisted-objects
1. Go to this page and download the library: Download everzet/persisted-objects 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/ */
everzet / persisted-objects example snippets
$repo = new FileRepository(TEMP_FILE, new AccessorObjectIdentifier('getId'));
$repo->save($user);
$user === $repo->findById($user->getId());
$repo->clear();
$repo = new InMemoryRepository(new CallbackObjectIdentifier(
function($obj) { return $obj->getFirstname() . $obj->getLastname(); }
);
$repo->save($user);
$user === $repo->findById($user->getFirstname() . $user->getLastname());
$repo->clear();