1. Go to this page and download the library: Download widuu/think-addons library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
widuu / think-addons example snippets
namespace addons\test;
use think\Addons;
/**
* Class Test
* @package addons\test
*/
class Test extends Addons
{
/**
* @Event("AppInit")
*/
public function init()
{
echo "监听 AppInit 事件";
}
/**
* @Event(["AppInit", "HttpRun"])
*/
public function run()
{
echo "监听 AppInit 和 HttpRun 事件";
}
/**
* 没有使用注释,直接监听方法名,监听 AddonsInit 事件
*/
public function AddonsInit()
{
echo "监听 AddonsInit 事件";
}
protected function install()
{
// TODO: Implement install() method.
}
protected function uninstall()
{
// TODO: Implement uninstall() method.
}
protected function enable()
{
// TODO: Implement enable() method.
}
protected function disable()
{
// TODO: Implement disable() method.
}
}