An open API service indexing awesome lists of open source software.

https://github.com/thinkphp6/thinkphp-extend-paginator

ThinkPHP6 分页扩展
https://github.com/thinkphp6/thinkphp-extend-paginator

paginator paginator-alpha php thinkphp thinkphp6 tp6

Last synced: 3 months ago
JSON representation

ThinkPHP6 分页扩展

Awesome Lists containing this project

README

          

# ThinkPHP ORM 分页驱动库

内含以下前端框架的分页驱动

* [Bootstrap4](#bootstrap4)
* [Bootstrap5](#bootstrap5)
* [Layui](#layui)
* [Amaze UI](#amaze-ui)
* [Foundation](#foundation)

## 安装

Usage is simple, to install, add the following to your project's composer.json:

```json
"repositories": [
{
"url": "https://github.com/thinkphp6/thinkphp-extend-paginator.git",
"type": "git"
}
]
```

Then add the library in the usual way using composer:

```
composer require thinkphp6/thinkphp-extend-paginator:dev-main
```

## 配置

### 1.服务提供定义文件里重新绑定服务

编辑`app/provider.php`文件,在该文件里重新绑定`think\Paginator`分页服务,该方法适用于ThinkPHP6,全局生效。

```php

return [
'think\Paginator' => \wanyi\thinkExtendPaginator\Bootstrap4::class
];

```

### 2.公共函数文件里绑定服务

编辑`app/common.php`文件,在该文件里重新绑定`think\Paginator`分页服务,该方法适用于ThinkPHP6,全局生效。
如果想单应用生效,请在应用的公共函数文件里重新绑定`think\Paginator`分页服务,如:`app/admin/common.php`。

```php
// 设置服务注入
\think\facade\App::bind('think\Paginator', \wanyi\thinkExtendPaginator\Bootstrap4::class);
```

如果只想一个地方生效,可以在进行分页查询前,使用该代码重新绑定`think\Paginator`分页服务。

```
// 设置服务注入
\think\facade\App::bind('think\Paginator', \wanyi\thinkExtendPaginator\Bootstrap4::class);

// 获取users表数据并进行分页
$list = \think\facade\Db::table('users')->paginate();
```

### 3.配置文件里定义分页类
编辑`config/paginate.php`文件
修改`type`配置项的值为`\wanyi\thinkExtendPaginator\Bootstrap4::class`,
该方法仅适用于ThinkPHP5.1.
```php
return [
'type' => \wanyi\thinkExtendPaginator\Bootstrap4::class,
];
```

## 已支持的前端框架

### Bootstrap4 - 5
框架官方文档:https://getbootstrap.com/docs/4.0/components/pagination/
框架官方文档:https://getbootstrap.com/docs/5.0/components/pagination/
```php
\think\facade\App::bind('think\Paginator', \bigDream\thinkPaginatorDriver\Bootstrap4::class);
\think\facade\App::bind('think\Paginator', \bigDream\thinkPaginatorDriver\Bootstrap5::class);
```

### Layui
框架官方文档:https://www.layui.com/doc/modules/laypage.html
```php
\think\facade\App::bind('think\Paginator', \bigDream\thinkPaginatorDriver\Layui::class);
```

### Amaze UI
框架官方文档:https://amazeui.clouddeep.cn/css/pagination/
```php
\think\facade\App::bind('think\Paginator', \bigDream\thinkPaginatorDriver\AmazeUI::class);
```

### Foundation
框架官方文档:https://foundation.zurb.com/sites/docs/pagination.html
```php
\think\facade\App::bind('think\Paginator', \bigDream\thinkPaginatorDriver\Foundation::class);
```

## 说明
- 在bigDream/thinkPaginatorDriver 上修改,二次发布。
[https://github.com/big-dream/think-paginator-driver][1]

## 其它
你所用的前端框架不在这里?欢迎提交PR,或者在Issues里告诉我。