PHPackages                             windwork/pager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. windwork/pager

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

windwork/pager
==============

windwork pager components,Windwork 分页组件

0.5.0(8y ago)071MITPHPPHP &gt;=5.5.0

Since May 11Pushed 8y agoCompare

[ Source](https://github.com/windwork/wf-pager)[ Packagist](https://packagist.org/packages/windwork/pager)[ RSS](/packages/windwork-pager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (3)Used By (0)

windwork 分页组件
=============

[](#windwork-分页组件)

通过设置总记录数和每页显示记录数，计算出分页导航参数并可生成分页导航html。 我们提供了3种不同的分页显示模板，如果不能满足你的需要，可自己编写分页模板。

安装
--

[](#安装)

该组件已包含在Windwork框架中，如果你已安装Windwork框架则可以直接使用。

- 安装方式一：通过composer安装（推荐）

```
composer require windwork/wf

```

- 安装方式二：传统方式安装
    [下载源码](https://github.com/windwork/wf/releases)后，解压源码到项目文件夹中，然后require\_once $PATH\_TO\_WF/core/lib/Loader.php文件，即可自动加载组件中的类。

使用案例
----

[](#使用案例)

```

// $userObj = new \app\user\model\UserModel();
// $total = $userObj->find()->count(); // 总用户数

$total = 125; // 总共记录数
$rows  = 20; // 每页显示记录数
$pager = new \wf\pager\Pager($total, 12);
// 在Windwork控制器中使用 $pager = pager($total, $rows);

// 让sql知道从第几行获取数据，获取多少行
// $userObj->find()->fetchAll($pager->offset, $pager->rows);

// 显示分页导航条
echo $pager->getHtml();

```

分页条显示风格
-------

[](#分页条显示风格)

可以选择使用不同风格显示导航条

- simple 默认简介风格导航
- mobile 使用于手机界面的导航
- complex 复杂导航，一般用在管理后台

### 方式1、在构造函数中指定模板风格

[](#方式1在构造函数中指定模板风格)

```
// 导航选择使用模板
$tpl = 'simple'; // simple|mobile|complex

$pager = new \wf\pager\Pager($total, 12, '', ['tpl' => $tpl]);
$pager->getHtml()

```

### 方式2、在模板中选择主题风格

[](#方式2在模板中选择主题风格)

当我们视图手机版和电脑版分开的时候，可以在视图中直接调用不同风格的分页导航条以适应不同的客户端。

```
// 控制器中
$pager = new \wf\pager\Pager($total, 10);

// PC版视图中使用默认分页导航条
{$pager->getHtml('complex')}

// 手机版视图中使用手机分页导航条
{$pager->getHtml('mobile')}

```

分页样式案例
------

[](#分页样式案例)

```

.pagination { margin: 20px auto; padding: 0; height: 36px; font-size: 14px; }
.pagination li { display: inline; }
.pagination li a { display: inline; float: left; line-height: 36px; margin-left: -1px; padding: 0 12px; border: 1px solid #e0e0e0; position: relative; text-decoration: none; }
.pagination li a:hover { background: #f8f8f8; }
.pagination li.current a {background: #f8f8f8;}
.pagination li a span { color:#2a6496; }
.pagination li.current a span {color: #000; font-weight: bold; }
.pagination li.paging-select { line-height: 36px; float: right; color:#999; }
.pagination li.paging-select span { font-size: 12px; }
.pagination li.paging-select select { border: 1px solid #e0e0e0; height: 28px; padding: 0 3px; }

.pagination.mobile { font-size: 0; text-align: center; }
.pagination.mobile li { display: inline-block; }
.pagination.mobile li a span { font-size: 14px; }

```

高级功能
----

[](#高级功能)

### 1、自定义分页参数

[](#1自定义分页参数)

可配置参数：

```
$args = [
    'argSeparator'   => '&',      // 参数分隔符号
    'valSeparator'   => '=',      // 参数变量名和值的分隔符
    'pageVar'        => 'page',   // 分页页码的url请求变量名
    'rowsVar'        => 'rows',   // 每页行数的url请求变量名
    'rows_max'       => 100,      // 每页允许最多记录数
    'tpl'            => 'simple', // 默认分页样式，mobile）手机分页, simple）简单分页, complex）复杂分页
];

```

```
$pager = new Pager(200, 10);
$pager->uri = 'http://localhost/demo/xx';

// 得到默认格式的分页链接
// http://localhost/demo/xx?rows=10&page=2
$url = $pager->getPageUrl(2);

// 通过设置参数获得自定义的分页变量分隔符
$args = [
    'argSeparator'   => '/',  // 参数分隔符号
    'valSeparator'   => ':', // 变量和值的分隔符
];
$pager = new Pager(200, 10, '', $args);
$pager->uri = 'http://localhost/demo/xx';

// 得到个性化格式的分页链接：
// http://localhost/demo/xx/rows:10/page:2
$url = $pager->getPageUrl(2);

```

### 要了解更多？

[](#要了解更多)

> - [官方完整文档首页](http://docs.windwork.org/manual/)
> - [官方源码首页](https://github.com/windwork)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~43 days

Total

2

Last Release

3242d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/500cd48271ed61b12fbac17502e33a2b7ff364948c9ffe2d4a86d5d4d63540fb?d=identicon)[windwork](/maintainers/windwork)

---

Top Contributors

[![cmpan](https://avatars.githubusercontent.com/u/399927?v=4)](https://github.com/cmpan "cmpan (18 commits)")

---

Tags

pagerpaginationpagerpaginationpaging

### Embed Badge

![Health badge](/badges/windwork-pager/health.svg)

```
[![Health](https://phpackages.com/badges/windwork-pager/health.svg)](https://phpackages.com/packages/windwork-pager)
```

###  Alternatives

[aplus/pagination

Aplus Framework Pagination Library

2091.6M3](/packages/aplus-pagination)[kop/yii2-scroll-pager

Infinite AJAX scrolling for Yii2 ListView widget

180706.5k10](/packages/kop-yii2-scroll-pager)[beberlei/porpaginas

Library that generically solves several pagination issues with DAO/repository abstractions.

163612.6k11](/packages/beberlei-porpaginas)[stefangabos/zebra_pagination

A generic, Twitter Bootstrap compatible, PHP pagination library that automatically generates navigation links

11122.9k](/packages/stefangabos-zebra-pagination)[ashleydawson/simple-pagination

Simple, lightweight and universal service that implements pagination on collections of things

18161.2k2](/packages/ashleydawson-simple-pagination)[ttskch/paginator-bundle

The most thin, simple and customizable paginator bundle for Symfony

1113.2k](/packages/ttskch-paginator-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
