koine/repository

Abstraction classes for repositories

v1.0 2016-01-13 15:03 UTC

This package is not auto-updated.

Last update: 2024-12-21 20:24:54 UTC


README

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