Skip to content

Latest commit

 

History

History
108 lines (80 loc) · 3.07 KB

README.md

File metadata and controls

108 lines (80 loc) · 3.07 KB

ThinkPHP ORM 分页驱动库

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

安装

Usage is simple, to install, add the following to your project's composer.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,全局生效。

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

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

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

return [
    'type' => \wanyi\thinkExtendPaginator\Bootstrap4::class,
];

已支持的前端框架

Bootstrap4 - 5

框架官方文档:https://getbootstrap.com/docs/4.0/components/pagination/
框架官方文档:https://getbootstrap.com/docs/5.0/components/pagination/

\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

\think\facade\App::bind('think\Paginator', \bigDream\thinkPaginatorDriver\Layui::class);

Amaze UI

框架官方文档:https://amazeui.clouddeep.cn/css/pagination/

\think\facade\App::bind('think\Paginator', \bigDream\thinkPaginatorDriver\AmazeUI::class);

Foundation

框架官方文档:https://foundation.zurb.com/sites/docs/pagination.html

\think\facade\App::bind('think\Paginator', \bigDream\thinkPaginatorDriver\Foundation::class);

说明

其它

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