PHP code example of resgen / lumen-proc

1. Go to this page and download the library: Download resgen/lumen-proc 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/ */

    

resgen / lumen-proc example snippets



class ExampleCommand extends LoopingCommand
{
    /** {@inheritDoc} */
    protected $name = 'resgen';

    /** {@inheritDoc} */
    protected $signature = 'resgen:example';

    /** {@inheritDoc} */
    protected function init()
    {
        // Called prior to the first loop
        // returning `false` will cause the command to stop & exit
    }

    /** {@inheritDoc} */
    protected function loop()
    {
        // Called repeatedly until an exit signal is received or thrown

        return 1;   // Return the number of seconds to sleep/idle until loop() should be called again
    }

    /** {@inheritDoc} */
    protected function exiting()
    {
        // Called just prior to command handler returns for cleanup
    }
}


class ExampleCommand extends LoopingCommand
{
    /* ...snip... */
    protected function init()
    {
        $this->cron()
            ->dirCheck('/tmp')
            ->every(5);
            
        $this->cron()
            ->report()
            ->every(60);
    }
    
    /** Check that $dir exists, if not, create it. */
    protected function dirCheck($dir) 
    {
        if(!is_dir($dir)) {
            mkdir($dir, 0777, true);
        }
    }
    
    /** Report on the current state every 60 seconds */
    protected function report()
    {
        Log::info('Sample report every 60 seconds.');
    }
    
}
bash
RUN docker-php-ext-install pcntl