box4b / systembundle
系统包装包
1.0.10
2017-04-25 13:36 UTC
Requires
- php: >=5.3.3
- doctrine/doctrine-bundle: ~1.2
- doctrine/orm: ~2.2,>=2.2.3
- symfony/symfony: 2.*
README
使用Symfony事件绑定Linux系统事件(cron,init)。
配置
###AppKernel
将以下内容添加到AppKernel的registerBundles()中
new box4b\SystemBundle\SystemBundle()
###对于Cron
创建一个包含以下内容的/etc/cron.d/box4bsystem
文件
* * * * * [YOUR_USER] /usr/bin/php [PATH_TO_SYMFONY_PROJECT]/app/console box4b:cron --env=prod > /dev/null 2> /dev/null
###对于Init / Systemd
创建一个文件,调用/usr/bin/php [PATH_TO_SYMFONY_PROJECT]/app/console box4b:init [start|stop]
用法
使用Symfony事件监听器系统监听事件
###Init
- box4b\SystemBundle\Event\InitEvent::EVENT_START
- box4b\SystemBundle\Event\InitEvent::EVENT_STOP
###Cron
- box4b\SystemBundle\Event\CronEvent::EVERY_MINUTE
- box4b\SystemBundle\Event\CronEvent::EVERY_FIVE_MINUTES
- box4b\SystemBundle\Event\CronEvent::EVERY_HOUR
- box4b\SystemBundle\Event\CronEvent::EVERY_DAY
- box4b\SystemBundle\Event\CronEvent::EVERY_WEEK
享受吧 :)