irfantoor/pagination
Composer 安装命令:
composer require irfantoor/pagination
包简介
Creates normal or reversed pagination
README 文档
README
A simple pagination library, which can be used to create the pagination links at the bottom of a page.
Quick Start
example:
<html>
<head>
<style>
.pagination a {text-decoration: none}
/* from bootstrap.css */
.pagination {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
padding-left: 0;
list-style: none;
border-radius: 0.25rem;
}
.page-link {
position: relative;
display: block;
padding: 0.5rem 0.75rem;
margin-left: -1px;
line-height: 1.25;
color: #007bff;
background-color: #fff;
border: 1px solid #dee2e6;
}
.page-link:hover {
color: #0056b3;
text-decoration: none;
background-color: #e9ecef;
border-color: #dee2e6;
}
.page-link:focus {
z-index: 2;
outline: 0;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}
.page-link:not(:disabled):not(.disabled) {
cursor: pointer;
}
.page-item:first-child .page-link {
margin-left: 0;
border-top-left-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
}
.page-item:last-child .page-link {
border-top-right-radius: 0.25rem;
border-bottom-right-radius: 0.25rem;
}
.page-item.active .page-link {
z-index: 1;
color: #fff;
background-color: #007bff;
border-color: #007bff;
}
.page-item.disabled .page-link {
color: #6c757d;
pointer-events: none;
cursor: auto;
background-color: #fff;
border-color: #dee2e6;
}
</style>
</head>
<body>
<?php
require dirname(__DIR__) . "/vendor/autoload.php";
use IrfanTOOR\Pagination;
$p = new Pagination();
echo $p->html(100); # normal pagination
echo $p->html(100, true); # reverse pagination
?>
</body>
</html>
Construct Pagination
method: new Pagination($options = [])
parameters:
- array $options Array of pagination options
example:
<?php use IrfanTOOR\Pagiation; $pagination = new Pagination([ 'base_url' => '/blog//', 'per_page' => 20, 'int_pages' => 9, ]);
Set the base url
method: setBaseUrl(string $url)
parameteres:
- string url - base url to be used while doing the pagination default is '/'
returns: nothing
example:
<?php $pagination->setBaseUrl('/users//');
Set the page component name
method: setPageComponent(string $page_component)
parameteres:
- string $page_component Name of the page component in URL, used to extract the page number from $_GET
returns: nothing
example:
<?php $pagination->setPageComponent('page_no'); # now the url will be like : .../?page_no=3
Set the number of entries per page
method: setPerPage(int $per_page)
parameteres:
- int $per_page - number of entries to be displayed on a page default is 10
returns: nothing
example:
<?php $per_page = 100; $pagination->setPerPage($per_page);
Number of intermediate pages
method: setIntermediatePages(int $int_pages)
parameteres:
- int $int_page - number of intermediate pages to be displayed in the pagination bar, default is 5 (should always be odd)
returns: nothing
example:
<?php $pagination->setIntermediatePages(7);
Current page
Current page number as passed through $_GET global variable or 1 Note: This can be overridden, to apply any kind of normalizations etc.
method: currentPage()
parameteres: none
returns:
int Current page number
example:
<?php $page = $pagination->currentPage();
Retrieve the pagination html
NOTE: it retrieves the current page from ```$_GET['page']
method: setIntermediatePages(int $int_pages)
parameteres:
- int $total Total number of records
- bool $reverse Normal (false), or Reverse pagination (true)
returns:
Html block which can be displayed directly in an html page
example:
<?php # ... $total = 10000; # from a database query for example echo $pagination->html($total); # normal pagination echo $pagination->html($total, true); # reverse pagination
irfantoor/pagination 适用场景与选型建议
irfantoor/pagination 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 01 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pagination」 「normal」 「asending」 「desending」 「reversed」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 irfantoor/pagination 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 irfantoor/pagination 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 irfantoor/pagination 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy API keys - Because laravel/passport is hard.
Deterministic pseudo-random generators library with dozens of useful functions and several sources of randomness
A bundle to calculate normal distribution and other related stuff
Provides a Data Grid tables for your Symfony project.
Normalize an index range from user input
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-23