pagerfanta/doctrine-orm-adapter
pagerfanta/doctrine-orm-adapter is a Doctrine ORM adapter for Pagerfanta, a pagination library. It bridges Doctrine ORM queries with Pagerfanta’s pagination abstraction, enabling consistent pagination across applications using Doctrine.doctrine/orm or illuminate/database extensions) where:
paginate().Illuminate\Pagination\LengthAwarePaginator instead).doctrine/orm (via illuminate/database or standalone). Laravel’s native Eloquent is not Doctrine ORM, so this adapter is only relevant if using Doctrine directly.pagerfanta/pagerfanta-bundle) is Symfony-focused. Direct use may require manual wiring.pagerfanta/pagerfanta (≥2.0).doctrine/orm (≥2.5).RequestStack or Router if using Pagerfanta’s view helpers.?page=2) may require custom middleware.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Doctrine ORM Overhead | High | Evaluate if Doctrine is justified vs. Eloquent. |
| Symfony Dependency | Medium | Abstract Pagerfanta’s Symfony components. |
| Pagination Logic | Medium | Test edge cases (e.g., empty results, large offsets). |
| Laravel Ecosystem | Low | Prefer native paginate() unless Pagerfanta features are critical. |
RequestStack) elsewhere?cursor() or simplePaginate()?Illuminate\Pagination\LengthAwarePaginator (simpler, no Doctrine dependency).pagerfanta/eloquent-adapter is more idiomatic.DQL queries, native hydration).composer require doctrine/orm
config/database.php or custom Doctrine config).composer require pagerfanta/doctrine-orm-adapter pagerfanta/pagerfanta
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\DoctrineORMAdapter;
$query = $entityManager->createQuery('SELECT u FROM User u');
$adapter = new DoctrineORMAdapter($query);
$pagerfanta = new Pagerfanta($adapter);
$pagerfanta->setMaxPerPage(10);
Request handling with Laravel’s Request:
$page = request()->query->getInt('page', 1);
$pagerfanta->setCurrentPage($page);
getIterator() or use a custom view.pagerfanta/pagerfanta ≥2.0 (LTS).PaginationServiceProvider.getCurrentPageResults() manually.paginate().ParameterBag).COUNT caching).HYDRATE_SCALAR for read-only pagination.maxPerPage limits are enforced to avoid memory issues.| Scenario | Impact | Mitigation |
|---|---|---|
| Doctrine connection failure | Pagination breaks silently. | Add retry logic or fallback to simple pagination. |
Invalid page parameter |
Empty results or errors. | Validate input (e.g., max(1)). |
| Large offset queries | Timeouts or memory exhaustion. | Use setMaxPerPage() limits. |
| Pagerfanta version conflicts | Runtime errors. | Pin versions in composer.json. |
How can I help you explore Laravel packages today?