PHP code example of sw2eu / cron-command

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

    

sw2eu / cron-command example snippets




namespace App\Commands;

use Sw2\CronCommand\Task;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Class AwesomeTask
 * @package App\Commands
 *
 * @cron 0 0 * * 0
 */
class AwesomeTask extends Task
{
	/** @var MySuperAwesomeService @inject */
	public $youCanInjectYourServices;

	protected function configure()
	{
		$this->setName('cron:be-awesome');
		$this->setDescription('Totally awesome task that would totally change your life');
	}

	/**
	 * @param InputInterface $input
	 * @param OutputInterface $output
	 * @return void
	 */
	protected function execute(InputInterface $input, OutputInterface $output)
	{
		// do something awesome
		$output->writeln("<info>I am awesome task!</info>");
	}

}
sh
$ php www/index.php cron:runner