PHP code example of miksoftware / daemon-bundle

1. Go to this page and download the library: Download miksoftware/daemon-bundle 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/ */

    

miksoftware / daemon-bundle example snippets


    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new MikSoftware\DaemonBundle\MikSoftwareDaemonBundle()
            // ...
        );
    }
    

    
    
    namespace <Application>\<Bundle>\Command;
    
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    use Symfony\Component\Console\Input\InputArgument;
    use MikSoftware\DaemonBundle\Commnad\DaemonizedCommand;
    
    class <Name>Command extends DaemonizedCommand
    {
        protected function configureDaemonCommand()
        {
            $this
                ->setName('<name>')
                ->setDescription('<description>')
                ->setHelp('Usage <info>php app/console <name> start|stop|restart</info>');
        }
    
        /**
         * Starts asynchronous release:deploy commands for queue items.
         */
        protected function daemonLogic()
        {
            // Log something
            $this->getContainer()->get('logger')->info('Daemon is running!');
            // And then sleep for 5 seconds
            $this->daemon->iterate(1);
        }
    }
    


    // ...
    class <Name>Command extends DaemonizedCommand
    {
        protected function configureDaemonCommand()
        {
            $this->addMethods(array('status'));        
            $this
                ->setName('<name>')
                ->setDescription('<description>')
                ->setHelp('Usage <info>php app/console <name> start|stop|restart</info>');
        }
            
        // ...
            
        protected function status()
        {
            // TODO: implement the new method
        }
    }
bash
    mik@mbp:~$ php app/console <name> start
    mik@mbp:~$ php app/console <name> stop
    mik@mbp:~$ php app/console <name> restart