承接 hectororm/pagination 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hectororm/pagination

最新稳定版本:v1.3.0

Composer 安装命令:

composer require hectororm/pagination

包简介

Hector Pagination

README 文档

README

Latest Version Packagist Dependency Version Software license

Note

This repository is a read-only split from the main HectorORM repository.

For contributions, issues, or more information, please visit the main HectorORM repository.

Do not open issues or pull requests here.

Hector Pagination provides a set of interfaces and implementations for handling pagination in PHP applications. It supports multiple pagination strategies: offset-based, cursor-based (keyset), and range-based pagination.

📖 Full documentation

Installation

composer require hectororm/pagination

Pagination Types

Type Class Use Case
Offset OffsetPagination Simple page-based navigation
Cursor CursorPagination Keyset pagination for large datasets
Range RangePagination RFC 7233 style (Content-Range headers)

Quick Start

use Hector\Pagination\OffsetPagination;
use Hector\Pagination\Paginator\OffsetPaginator;

// 1. Create paginator (injectable as service)
$paginator = new OffsetPaginator(
    pageParam: 'page',
    perPageParam: 'per_page',
    defaultPerPage: 15,
    maxPerPage: 100,
);

// 2. Parse request: ?page=3&per_page=20
$request = $paginator->createRequest($serverRequest);

// 3. Query your data
$results = $repository->findAll($request->getLimit(), $request->getOffset());

// 4. Build pagination
$pagination = new OffsetPagination(
    items: $results,
    perPage: $request->perPage,
    currentPage: $request->page,
    hasMore: count($results) >= $request->perPage,
);

// 5. Prepare response with Link headers
$response = $paginator->prepareResponse($response, $serverRequest->getUri(), $pagination);

Features

  • Paginators: High-level API for request parsing and response preparation
  • Navigators: Generate navigation links (first, prev, next, last)
  • URI Builders: Customizable query parameter generation
  • Cursor Encoders: Base64 and HMAC-signed cursors
  • Cursor Storage: Server-side cursor state (PSR-16 cache)
  • JSON Serialization: All pagination classes implement JsonSerializable
  • PSR-7 Compatible: Works with any PSR-7 implementation

📖 See full documentation for all features

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 2

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固