koine / repository
Abstraction classes for repositories
v1.0
2016-01-13 15:03 UTC
Requires
- php: >=5.3
- zendframework/zend-hydrator: ^2.0
Requires (Dev)
- phpunit/phpunit: ~4.6
- satooshi/php-coveralls: ^1.0
- zendframework/zend-eventmanager: ^2.5.1
- zendframework/zend-filter: ^2.5.1
- zendframework/zend-inputfilter: ^2.5.1
- zendframework/zend-serializer: ^2.5.1
- zendframework/zend-servicemanager: ^2.5.1
This package is not auto-updated.
Last update: 2024-11-09 19:38:30 UTC
README
Repository pattern for PHP
Code information:
Package information:
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
- Learn composer. You should not be looking for an alternative install. It is worth the time. Trust me ;-)
- Follow this set of instructions
Issues/Features proposals
Here is the issue tracker.