1. Go to this page and download the library: Download psf1/cron-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/ */
psf1 / cron-bundle example snippets
// src/Cron/CacheClearCron.php
namespace App\Cron;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\HttpKernel\KernelInterface;
use VM\Cron\JobInterface;
/**
* Run cache clear job.
*/
class CacheClearCron implements JobInterface
{
protected ?Application $application;
/**
* @param KernelInterface $kernel
*/
public function __construct(KernelInterface $kernel)
{
$this->application = new Application($kernel);
$this->application->setAutoExit(false);
}
/**
* Execute job.
*
* @return void
*
* @throws \Exception
*/
public function run(): void
{
$input = new ArrayInput([
'command' => 'cache:clear',
]);
$output = new NullOutput();
$this->application->run($input, $output);
}
}
php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new CronBundle\CronBundle(),
);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.