PHP code example of koine / repository

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

    

koine / repository example snippets



$storage = new \Koine\Repository\Storage\MySql($pdo, 'users');
$repository = new \Koine\Repository\Repository($storage);
$respository->setHydrator($hydrator)
  ->setEntityPrototype(new User());

// all
$users = $respository->findAll();

// first foo
$foo = $respository->findOneBy(array(
    'name' => 'foo',
));

// by name foo
$foos = $respository->findAllBy(array(
    'name' => 'foo',
));

// creating
$repository->persist(new User('bar'));

// changing
$foo->setName('bar');
$repository->persist($foo);

// removing
$repository->remove($foo);


// sorting foos
$youngToOldFoos = $foos->sort(new MethodSorter('getBirthday'));