wake/pager 问题修复 & 功能扩展

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

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

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 wake/pager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-24