php-pagination/php-pagination
Composer 安装命令:
composer require php-pagination/php-pagination
包简介
PHP Pagination Class with 4 types: Simple Pagination, Google Pagination, Digg/PHPBB Pagination Style.
README 文档
README
PHP paging class with 4 different page types:
Simple Pagination:Creates a simple pagination similar to Google.
PHPBB/Digg Pagination:Paging in the same style as the PHPBB CMS/Digg. In addition to the normal pages you have the markers with the last pages and home pages.
Jumping Pagination:Paging where the markers "jump" after a certain value, for example: Every 10 page markers are displayed from 1 to 10 - 11 to 20 - 21 to 30 and so on.
Google Pagination:PHP paging is the same as that used by Google to display search results.
See the examples folder for using the class easily.
Features
v2.0.1Added method to get start for sql clauses.v2.0.0The methods were refactored, unit tests added, examples and design patters.
Important informations
-
You need PHP 7.0 or higher to use this class.
-
I used the strategy pattern to create different pagination types. I put the examples in the examples folder. This pagination returns only one PHP ArrayObject, so you create the layout part as you wish.
-
The pagination always returns the first page, last page, previous, next, an ArrayObject with total pages, 2 methods to advance or retreat a deternated number of pages and finally another ArrayObject with the markers following the paging style logic chosen.
-
This is a free project, feel free to use it in your projects, even if they are commercial. You can also contribute tips, new features and fixes.
Example of use
To use this class you must follow the code below. Do not forget to access the examples folder here in the repository with the usage examples for each page type. Also access rafaacademy.com for tips and tutorials on php and use of this class.
Install: composer require php-pagination/php-pagination
<?php require '../vendor/autoload.php'; use Pagination\Pagination; use Pagination\StrategySimple; if ( isset($_GET['page']) && is_numeric($_GET['page']) ) $page = $_GET['page']; else $page = 1; //use pagination class with results, per page and page $pagination = new Pagination(1000, 10, $page); //get first page $pagination->getFirstPage(); //get last page $pagination->getLastPage(); //get previous page $pagination->getPreviousPage(); //get next page $pagination->getNextPage(); //get all indexes $all = $pagination->getAllIndexesOfPages(); $iteratorAll = $all->getIterator(); //get indexes in page stylized $indexes = $pagination->getIndexes(new StrategySimple(15)); $iterator = $indexes->getIterator(); //get start for sql queries (optional - Note: This paging does not use a bank connection) $pagination->getStartForSqlQueries();
To navigate between indexes you need to learn how to work with the ArrayInterator and ArrayObject of PHP.
php-pagination/php-pagination 适用场景与选型建议
php-pagination/php-pagination 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.05k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2017 年 06 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「page」 「paging」 「paginator」 「pagination」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 php-pagination/php-pagination 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 php-pagination/php-pagination 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 php-pagination/php-pagination 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table.
Plug-ins for DataTables
This package helps you use bitwise enums in PHP and Laravel.
Symfony DataGridBundle
Symfony pagination bundle with support for arrays, Doctrine ORM repositories, queries, Twig rendering, and filter building
MongoDB Adapter to be used with Laminas Paginator
统计信息
- 总下载量: 12.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-06-23