componenta/http-paginate-interceptor
Composer 安装命令:
composer require componenta/http-paginate-interceptor
包简介
HTTP pagination result interceptor for Componenta
README 文档
README
HTTP interceptor for componenta/interceptor that turns PaginatorInterface into Componenta\Http\ResourcePaginator with prev / next links.
Boundary
This package contains one attribute: #[Paginate]. The attribute itself implements InterceptorInterface, so it does not need a separate #[Intercept(...)].
It does not fetch data and does not create paginators. The route handler must return Componenta\Stdlib\PaginatorInterface.
Installation
composer require componenta/http-paginate-interceptor
Quick Start
use Componenta\Interceptor\Http\Attribute\Respond; use Componenta\Interceptor\Http\Paginate; final class PostController { #[Respond(200, 'application/json')] #[Paginate] public function index(PostListQuery $query): PaginatorInterface { return $this->posts->list($query); } }
If the result does not implement PaginatorInterface, #[Paginate] returns it unchanged.
Response Fields
By default ResourcePaginator receives:
count, prev, next, range, page, results
You can keep only selected metadata fields. results is always added automatically:
use Componenta\Interceptor\Http\Paginate; #[Paginate(Paginate::FIELD_COUNT, Paginate::FIELD_NEXT)] public function index(): PaginatorInterface {}
HTTP Request In Context
prev and next generation requires the current ServerRequestInterface. componenta/router-app passes the HTTP request into callable context when executing route handlers. If #[Paginate] receives a paginator without that request attribute, it throws LogicException.
Scope
#[Paginate] is restricted to Scope::HTTP.
License
MIT
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-17