evilband7 / doctrine-data
Bring SpringData features into PHP
0.1.1
2016-09-14 19:05 UTC
Requires
- php: ~7.0
- doctrine/common: ~2.5
- doctrine/orm: ~2.5
- evilband7/php-common-util: *
- myclabs/php-enum: ~1.0
- psr/log: ~1
- zendframework/zend-code: ~3.0 || ~2.7
- zendframework/zend-stdlib: ~3.0 || ~2.7
Requires (Dev)
- jms/serializer: ~1.2
- monolog/monolog: *
- phpunit/phpunit: *
This package is not auto-updated.
Last update: 2025-01-13 15:20:38 UTC
README
Extends doctrine repository feature with pagination support. (Inspired from SpringData project.)
Feature
- Create your own Repository class without implementation (Interface Only)
- Also support custom implementation.
- Support Pagination with strong type pagination stubs (DoctrineData\Pagination\*)
- Make Doctrine2 Repository more stronger.
- Didn't support Doctrine2 Magic Method by default (You need to define that method in an Interface. Because we focus on maintenance. how should people know which magic method currently used on a project.)
Status
- Under development.
- Will be available soon.
- Feel free to fork and submit pull request. xD
Basic Repository Interface
interface EmployeeRepository extends DoctrineDataRepositoryInterface
{
/** @Query("select e from Employee e where e.name = ?1") */
public function findByDepartmentId(int $departmentId, PageableInterface $pageable);
}
/* @var $repository EmployeeRepository */
/* @var $page PageInterface */
$pageRequest = new PageRequest(1,10);
$repository = $em->getRepository(Employee::class);
$page = $repository->findByDepartmentId(1, $pageRequest);
foreach($page as $emp){
echo 'Name: ' . $emp->getName() ;
}