edo / daemons-bundle
一个简单的bundle,可以将您的Symfony命令转换为守护进程
v0.0.1
2015-08-18 15:56 UTC
Requires
- php: >=5.3.0
- ext-pcntl: *
- amphp/amp: ^1.0
- symfony/framework-bundle: ~2.1
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2021-09-18 01:54:10 UTC
README
一个工作示例
<?php namespace AppBundle\Command; use Edo\DaemonsBundle\Command\ContainerAwareDaemonCommand; use Symfony\Component\Console\Input\Input; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class KafkaConsumerCommand extends ContainerAwareDaemonCommand { protected function configure() { $this ->setName('kafka:consumer') ->setDescription('') ; } /** * * This function is called before the loop * * @param InputInterface $inputInterface * @param OutputInterface $outputInterface */ protected function initialize(InputInterface $inputInterface, OutputInterface $outputInterface) { } /** * * This function is the loop, it means you can use this function as while(1) * * @param InputInterface $input * @param OutputInterface $output */ private $string = ''; protected function execute(InputInterface $input, OutputInterface $output) { $this->string .= substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 204800); } /** * * This function is called inside register_shutdown_function() * * @param InputInterface $input * @param OutputInterface $output */ protected function terminate(InputInterface $input, OutputInterface $output) { } }