liming / think-plugin
thinkphp5.1扩展插件
dev-master
2021-06-06 12:41 UTC
Requires
- php: >=5.6.0
- topthink/framework: 5.1.*
This package is not auto-updated.
Last update: 2024-05-20 02:54:13 UTC
README
thinkphp5.1扩展plugin插件扩展,解决可安装式插件开发,缓慢更新中...
注意:生产环境需谨慎使用
安装:
composer require liming/think-plugin:dev-master
一、目录结构
application
plugin
├── helloworld
│ ├── controller
│ │ ├── Index.php
│ │ └── ...
│ ├── model
│ ├── ├── Index.php
│ ├── ├── ...
│ ├── validate
│ ├── ├── Index.php
│ ├── ├── ...
│ ├── view
│ ├── ├── index
│ ├── ├── ├── index.html
│ ├── ├── ├── ...
│ ├── config.php // 插件配置文件
│ ├── function.php //自定义函数文件
└── ...
...
二、开发规范
- 插件命名规则小写加下划线命名
- 其他命名参考
thinkphp5.1
官方推荐命名方式
三、配置文件
- 配置文件为结构图中的
config.php
,调用为config('plugin.test')
thinkphp5.1一致,注意必须为plugin.
四、基础控制器
plugin\Controller;
/**
* 返回视图、与thinkphp5.1一致
* @param $template 模板位置 1、空|当前请求方法名 当前方法对应视图 2、index/test 跨控制器调用 3、admin@layout/layout 调用模块中的视图
*/
protected function fetch($template = '', $vars = [], $replace = [], $config = [])
五、助手函数
/**
* 插件跳转地址
* @param $action 跳转地址,默认当前地址
*/
plugin_url($action = '');