Skip to content

koinephp/repository

 
 

Repository files navigation

Koine Repository

Repository pattern for PHP

Code information:

Build Status Coverage Status Code Climate Scrutinizer Code Quality

Package information:

Latest Stable Version Total Downloads Latest Unstable Version License Dependency Status

Usage

<?php
$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);
<?php
// sorting foos
$youngToOldFoos = $foos->sort(new MethodSorter('getBirthday'));

Installing

Installing Via Composer

Append the lib to your requirements key in your composer.json.

{
    // composer.json
    // [..]
    require: {
        // append this line to your requirements
        "koine/repository": "*"
    }
}

Alternative install

Issues/Features proposals

Here is the issue tracker.

Lincense

MIT

Authors

Packages

No packages published

Languages

  • PHP 100.0%