neovav / events
一个带有事件通知器的PHP库
dev-master
2019-08-18 19:25 UTC
Requires
- php: ~7.0
- ext-mbstring: *
This package is auto-updated.
Last update: 2024-09-26 22:54:56 UTC
README
这是使用事件库与通知器的示例
入门
安装
对于neovav/Events的安装,运行
git clone https://github.com/neovav/Events
cd Events
composer install
用法
use \neovav\Events\Subscriber; use \neovav\Events\Notifier; use \neovav\Events\INotice; use \neovav\Events\Notice; use \neovav\Events\IEventData; require_once '..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php'; $func = function (INotice $notice) { echo "\r\n", 'DEBUG => ', $notice->getEventName(); if ($notice->isEventData()) var_dump($notice->getEventData()); }; try { $subscr_dbg = new Subscriber('DEBUG@Start', $func); Notifier::attach($subscr_dbg); } catch(Exception $e) {var_dump($e);}; $notice_dbg = new Notice(__FILE__,'DEBUG@Start'); Notifier::notify($notice_dbg); Notifier::detach($subscr_dbg);
更多示例请查看目录:samples 样本主文件在samples中:samples/sample.php