kgilden/pager
Composer 安装命令:
composer require kgilden/pager
包简介
A paginator library to split results into multiple pages
README 文档
README
Pager is a library to split results to multiple pages - any way you want them!
Features
- 5 built-in adapters for arrays, Doctrine ORM, ElasticSearch & MongoDB;
- safe subset of methods to not even count items;
- strategies to split pages inequally (i.e. 2 last pages merged);
- integrates nicely with Symfony's
HttpKernelto infer the current page; - provides a bundle to seamlessly integrate with Symfony;
Documentation
Usage
Two objects work together to split a set of items to pages: pager and adapter. Pagers act as factories for pages. Adapters allow concrete item sets to be paged (for example there's an adapter for Doctrine queries).
Here's an example with arrays (check out the docs for more):
<?php use KG\Pager\Pager; use KG\Pager\Adapter\ArrayAdapter; $list = ['apple', 'banana', 'cucumber', 'dragonfruit', 'eggplant']; $itemsPerPage = 2; $currentPage = 3; $pager = new Pager(); $page = $pager->paginate(new ArrayAdapter($list), $itemsPerPage, $currentPage); $page->isFirst(); // false $page->isLast(); // true - there's a total of 3 pages $page->getNumber(); // 3 - it's $currentPage count($page->getItems()); // 1 $page->getItems(); // ["eggplant"] ?>
Installation
Install using composer: composer.phar require kgilden/pager
Testing
Simply run phpunit in the root directory of the library for the full
test suite.
License
This library is under the MIT license.
kgilden/pager 适用场景与选型建议
kgilden/pager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20.38k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2015 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「library」 「pager」 「paginator」 「pagination」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kgilden/pager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kgilden/pager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kgilden/pager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Doctrine Collections adapter for Rekapager pagination library
Core functionality of Rekapager pagination library
Common classes for Symfony integration.
Symfony DataGridBundle
Symfony bundle for the Rekapager library
Inbox pattern process implementation for your Laravel Applications
统计信息
- 总下载量: 20.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 17
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-22