andrianzubko/sfw-paginator
最新稳定版本:0.1.4
Composer 安装命令:
composer require andrianzubko/sfw-paginator
包简介
SFW paginator
README 文档
README
This class intended for organization of page-by-page navigation on some data. Basically intended for construction of page-by-page navigation panels on websites.
Installation
composer require andrianzubko/sfw-paginator
Usage
// Making all calculations and storing results at class properties. // // All arguments are required and must contain only integer numbers. $pg = new \SFW\Paginator( $totalEntries, // total number of entries (>= 1) $entriesPerPage, // number of entries per page (>= 1) $pagesPerSet, // number of pages per set (>= 1) $currentPage // current number of page ); // Get some property $pg->totalEntries; // or get all in array with keys in snake case $pg->toArray()['total_entries'];
Properties
Slice params
-
$pg->startOfSlice - start position of the slice (>= 0)
-
$pg->endOfSlice - end position of the slice (>= 0)
-
$pg->lengthOfSlice - length of the slice (>= 1)
Statistics
-
$pg->totalEntries - total number of entries (>= 1) (copied from arguments)
-
$pg->entriesPerPage - number of entries per page (>= 1) (copied from arguments)
-
$pg->pagesPerSet - number of pages per set (>= 1) (copied from arguments)
Pages control
-
$pg->totalPages - total number of pages (>= 1)
-
$pg->currentPage - current number of page (>= 1) (corrected)
-
$pg->prevPage - previous number of page (>= 1 or false)
-
$pg->nextPage - next number of page (>= 1 or false)
Pages set control
-
$pg->startOfSet - start position of current set (>= 1)
-
$pg->endOfSet - end position of current set (>= 1)
-
$pg->pageOfPrevSet - nearest page number of the previous set (>= 1 or false)
-
$pg->pageOfNextSet - nearest page number of the next set (>= 1 or false)
-
$pg->numbersOfSet - numbers of set (one or more numbers in array)
Examples
Simple
<-- previous page | next page -->
/ \
$pg->prevPage $pg->nextPage
Advanced
$pg->currentPage
|
$pg->prevPage | $pg->nextPage
\ | /
<< < 6 [7] 8 9 10 > >>
/ / \ \
$pg->pageOfPrevSet / \ $pg->pageOfNextSet
/ \
$pg->startOfSet $pg->endOfSet
| |
[ $pg->numbersOfSet ]
Statistics
$pg->totalPages
/ $pg->totalEntries
Total pages: 20 /
Total records: 200
Shown from 61 to 70 records
\ \
\ $pg->startOfSlice + 1
$pg->endOfSlice + 1
Notes
-
Most simple way to check, needs to show navigation panel or not, is checking $pg->totalPages property. Needs only, if this property >1.
-
$pg->prevPage, $pg->nextPage, $pg->pageOfPrevSet and $pg->pageOfNextSet properties must be checked for false value before using.
andrianzubko/sfw-paginator 适用场景与选型建议
andrianzubko/sfw-paginator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 411 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 andrianzubko/sfw-paginator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 andrianzubko/sfw-paginator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 411
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2023-06-16