componenta/paginator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

componenta/paginator

Composer 安装命令:

composer require componenta/paginator

包简介

Paginator contract and immutable paginator implementation

README 文档

README

Offset-based paginator value object with array conversion.

Use it for read models and list endpoints that return a slice of results together with navigation metadata.

Installation

composer require componenta/paginator

Related Packages

Package Why it matters here
componenta/arrayable PaginatorInterface extends Arrayable.
componenta/http-responder Responders can serialize pagination results as JSON.
componenta/cycle DataFetcher can return paginated read-side results.
componenta/cqrs Query handlers commonly return Paginator from read scenarios.

Usage

use Componenta\Stdlib\Paginator;

$page = new Paginator(
    results: $posts,
    limit: 20,
    offset: 40,
    totalCount: 95,
);

$page->currentPage; // 3
$page->totalPages;  // 5
$page->hasNextPage; // true
$page->nextOffset;  // 60

Paginator implements PaginatorInterface, which extends Componenta\Arrayable\Arrayable.

Array Shape

toArray() returns:

  • results
  • totalCount
  • limit
  • offset
  • currentPage
  • totalPages
  • hasNext
  • hasPrev
  • range

range is null for an empty page. Otherwise it contains one-based result positions for the current slice.

Unknown Totals

totalCount may be null for infinite-scroll reads. In that mode:

  • totalPages is null
  • hasNextPage uses hasNextPageHint when provided
  • without a hint, hasNextPage falls back to count(results) >= limit

Fetchers can request one extra row, trim it, and pass an explicit hint for precise next-page detection without running a total-count query.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固