PHP code example of facile-it / terminable-loop-command
1. Go to this page and download the library: Download facile-it/terminable-loop-command 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/ */
facile-it / terminable-loop-command example snippets
namespace Acme\Command;
use Facile\TerminableLoop\AbstractTerminableCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class MyCommand extends AbstractTerminableCommand
{
public function __construct()
{
parent::__construct('my:command');
}
protected function commandBody(InputInterface $input, OutputInterface $output): int
{
$this->setSleepDuration(60);
// do something
if (! $this->shouldSleep()) {
// you can customize sleep duration during execution, even conditionally
$this->setSleepDuration(0);
}
return 0;
}
}