快速入门
创建插件的初始目录结构:
使用此命令会在目录下创建名为Example
的插件初始目录结构,参见目录结构。
注册插件
注册插件:
app/console plugin:register Example
app/console plugin:register Example --without-database
开发模式下,建议使用—without-database
选项。您可在执行此命令之后,使用:bin/phpmig migrate
命令来创建数据库,这样数据库的变更就纳入了phpmig
的管理,方便开发过程中调整数据库。插件注册后,即可在后台->教育云->ES应用->已购项目中查看。
卸载插件(默认不删除数据库):
卸载插件,删除数据库:
app/console plugin:remove Example --with-deleting-database
app/console plugin:remove Example --with-deleting-database --with-deleting-source
目录结构
如果您的插件名称为Demo
那么目录结构为:
元信息文件
即插件目录下的plugin.json
:
{
"name": "演示插件",
"author": "EduSoho官方",
"version": "1.0.0",
"support_version": "8.0.0"
}
- version:插件版本
- support_version: 支持EduSoho系统的版本
即插件目录下的DemoPlugin.php
:
<?php
namespace DemoPlugin;
use Codeages\PluginBundle\System\PluginBase;
class DemoPlugin extends PluginBase
{
/*
{
$biz = $this->container->get('biz');
parent::boot();
}
*/
}
DemoPlugin
类必须继承自Codeages\PluginBundle\System\PluginBase
类。- 可以通复写
boot()
方法往biz
中注入自定义服务。
Migrations 目录
plugins/DemoPlugin/Migrations/
:插件Migrations
目录路径