wake/pager
Composer 安装命令:
composer require wake/pager
包简介
A lightweight PHP paginator.
关键字:
README 文档
README
A lightweight PHP paginator.
Installation
Add in your composer.json with following require entry:
{
"require": {
"wake/pager": "*"
}
}
or using composer:
$ composer require wake/pager:*
then run composer install or composer update.
Usage: Pager
Use Pager without any ORM.
Use Pager\Pager; $pager = new Pager (); $pager->total (1000) // 1000 data items ->page (13) // Set current page to no.13 ->paging (); // First page: 1 echo $pager->pages->top; // Last page (total pages): 67 echo $pager->pages->end; // First page of page group: 8 echo $page->pages->first; // Last page of page group: 17 echo $page->pages->last; // Next page: 14 echo $page->pages->next; // Next 10 page: 24 echo $page->pages->next10; // Pages foreach ($pager->pages as $page) echo $page . "<br />"; // Page url foreach ($pager->pages as $page) echo $page->url . "<br />";
$pager->show ($show)
Set amount of items per page, default to 15.
// Display 12 items on each page. $pager->show (12);
$pager->total ($total)
Set total amount of items.
// Set total amount of 100. $pager->total (100);
$pager->size ($size)
Set amount of page list per page, default to 10.
// Display 5 pages of page group on each page - `1 2 3 4 5` $pager->size (5);
$pager->page ($page)
Set current page, default to 1.
// Set current to page 3 $pager->page (3);
$pager->dynamic (), $pager->fixed ()
List pages of page group dynamically or fixed, default is dynamic.
// List dynamically: `1 2 3 4 5` -> `2 3 4 5 6` -> `3 4 5 6 7` $pager->dynamic (); // List fixed: `1 2 3 4 5` -> `6 7 8 9 10` $pager->fixed ();
$pager->url ($pattern)
Set url pattern or handler function, default is pattern (:num).
// /?page=3 $pager->url ('/?page=(:num)'); // /?p=3 $pager->url (function ($pageItem) { return '/?p=' . $pageItem->num; });
$pager->paging ()
Calculate and build page items, must be called after all options are set.
$pager->paging ();
Usage: Pages
Container of page items.
Use Pager\Pager; $pager = new Pager (); $pager->total (1000) // 1000 data items ->page (13) // current page is no.13 ->paging (); $pages = $pager->pages;
$pages->top
First page of all pages, generally is 1.
$pages->end
Last page of all pages.
$pages->first
First page of page group.
$pages->last
Last page of page group.
$pages->total
Total amount of pages.
$pages->current, $pages->page
Current page.
$pages->next
Next page.
$pages->prev
Previous page.
$pages->next*N
Next N page.
// Next page $pages->next; $pages->next1; // Next 5 page $pages->next5;
$pages->prev*N
Previous N page.
// Previous page $pages->prev; $pages->prev1; // Previous 5 page $pages->prev5;
Usage: Page item
Page item.
Use Pager\Pager; $pager = new Pager (); $pager->total (1000) // 1000 data items ->page (13) // current page is no.13 ->paging (); $item = $pager->pages->first;
$item, $item->num
Number of the page, $item could be use as string directly.
echo $item; echo $item->num;
$item->url ()
Url of the page.
echo $item->url ();
Feedback
Please feel free to open an issue and let me know if there is any thoughts or questions 😃
License
Released under the MIT license
wake/pager 适用场景与选型建议
wake/pager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 236 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 08 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「orm」 「paginator」 「pagination」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wake/pager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wake/pager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wake/pager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Kinikit - PHP Application development framework MVC component
PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2
Symfony DataGridBundle
MongoDB Adapter to be used with Laminas Paginator
PeskyORM - annoying ORM that contains tons of exceptions and throws them when anything goes wrong
Provides a Data Grid tables for your Symfony project.
统计信息
- 总下载量: 236
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-08-24