承接 popphp/pop-paginator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

popphp/pop-paginator

Composer 安装命令:

composer require popphp/pop-paginator

包简介

Pop Paginator Component for Pop PHP Framework

README 文档

README

Build Status Coverage Status

Join the chat at https://discord.gg/TZjgT74U7E

Overview

pop-paginator is a component for handling pagination for large data sets. You can set multiple options to control the display of the pages and the links.

pop-paginator is a component of the Pop PHP Framework.

Install

Install pop-paginator using Composer.

composer require popphp/pop-paginator

Or, require it in your composer.json file

"require": {
    "popphp/pop-paginator" : "^4.0.3"
}

Top

Quickstart

use Pop\Paginator\Paginator;

$paginator = Paginator::createRange(42); // Returns a Pop\Paginator\Range object
echo $paginator;

Which will produce this HTML:

<span>1</span>
<a href="/?page=2">2</a>
<a href="/?page=3">3</a>
<a href="/?page=4">4</a>
<a href="/?page=5">5</a>

And if you clicked on page 3, it would render:

<a href="/?page=1">1</a>
<a href="/?page=2">2</a>
<span>3</span>
<a href="/?page=4">4</a>
<a href="/?page=5">5</a>

Top

Page Range

In the above example, a page range object renders a range of page links. With it, you can set a large number of pages and have it render "bookend" link before and after the range as the "previous" and "next" links. Pass the total number of items, the per page limit and the range limit:

use Pop\Paginator\Paginator;

$paginator = Paginator::createRange(4512, 10, 10); // Returns a Pop\Paginator\Range object
echo $paginator;

If we go to page 12, it would render:

<a href="/?page=1">&laquo;</a>
<a href="/?page=10">&lsaquo;</a>
<a href="/?page=11">11</a>
<span>12</span>
<a href="/?page=13">13</a>
<a href="/?page=14">14</a>
<a href="/?page=15">15</a>
<a href="/?page=16">16</a>
<a href="/?page=17">17</a>
<a href="/?page=18">18</a>
<a href="/?page=19">19</a>
<a href="/?page=20">20</a>
<a href="/?page=21">&rsaquo;</a>
<a href="/?page=452">&raquo;</a>

As you can see, it renders the "bookends" to navigate to the next set of pages, the previous set, the beginning or end of the set.

Top

Page Form

To have a cleaner way of displaying a large set of pages, you can use the form object, which renders a input form field.

use Pop\Paginator\Form;
$paginator = new Form(558); // Returns a Pop\Paginator\Form object
echo $paginator;

This will produce:

<a href="/?page=1">&laquo;</a>
<a href="/?page=13">&lsaquo;</a>
<form action="/" method="get">
    <div><input type="text" name="page" size="2" value="14" /> of 56</div>
</form>
<a href="/?page=15">&rsaquo;</a>
<a href="/?page=56">&raquo;</a>

So instead of a set a links in between the bookends, there is a form input field that will allow the user to input a specific page to jump to.

Top

Options

You can set many options to tailor the paginator object's look and functionality:

  • Number of items per page
  • Range of the page sets
  • Separator between the page links
  • Classes for the on/off page links
  • Bookend characters
    • start
    • previous
    • next
    • end
use Pop\Paginator\Form;
$paginator = new Form(558); // Returns a Pop\Paginator\Form object
$paginator->setBookends([
    'start'    => '&laquo;',
    'previous' => '&lsaquo;',
    'next'     => '&rsaquo;',
    'end'      => '&raquo;'
])

The start is the far left bookend that takes you back to the beginning. The previous is the left bookend that takes you to the previous page set. The next is the right bookend that takes you to the next page set. The end is the far right bookend that takes you all the way to the end.

Top

popphp/pop-paginator 适用场景与选型建议

popphp/pop-paginator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.24k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2014 年 12 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「paginator」 「pagination」 「pop」 「pop php」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 popphp/pop-paginator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 popphp/pop-paginator 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-12-08