Installation Add the bundle via Composer (though note the last release is from 2014—verify compatibility with your Laravel version or Symfony stack):
composer require c2is/bigfoot-cron-bundle
Register the bundle in config/bundles.php (Symfony) or manually bootstrap it if using Laravel’s Symfony integration.
Configuration
Locate config/bigfoot_cron.php (or define your own config) and set:
return [
'jobs' => [
'my_job' => [
'command' => 'app:cron-job',
'schedule' => '*/5 * * * *', // Every 5 minutes
'user' => 'www-data', // User to run as
'env' => 'production', // Environment
],
],
];
First Use Case
Define a Laravel Artisan command (e.g., app/Console/Commands/CronJob.php) and reference it in the config under command. Test locally with:
php artisan my_job
Command-Based Jobs
SendReportsCommand).config/bigfoot_cron.php with cron syntax:
'jobs' => [
'send_reports' => [
'command' => 'reports:send',
'schedule' => '0 3 * * *', // Daily at 3 AM
],
],
Environment-Specific Config Use Laravel’s config caching or Symfony’s environment variables to override schedules per environment:
'schedule' => env('CRON_SCHEDULE', '*/10 * * * *'), // Fallback to every 10 mins
Logging & Output Redirect command output to a log file for debugging:
'command' => 'app:cleanup >> /var/log/cron/cleanup.log 2>&1',
Artisan::call() in commands to leverage queues/jobs internally.CronEvent) are properly wired.cron via crontab -e with the bundle’s generated commands.Deprecated Symfony 2.x
Cron Syntax Errors
// ❌ Invalid: '0 0 * * *' (missing day-of-week)
// ✅ Valid: '0 0 * * 0' (Sunday at midnight)
Permission Issues
user in config has execute permissions for the command:
chmod +x artisan
sudo -u www-data php artisan my_job
No Built-in Queue Support
dispatch() inside the command.php artisan schedule:run
/var/log/cron.log or redirect output as shown above.CronEvent to log job executions:
public function onCron(CronEvent $event) {
Log::info("Job {$event->getJob()} executed at {$event->getTimestamp()}");
}
Custom Job Classes
Extend the bundle’s Job class to add metadata or pre/post hooks:
class CustomJob extends \Bigfoot\CronBundle\Job {
public function preExecute() {
Log::debug("Pre-execution for {$this->getCommand()}");
}
}
Dynamic Scheduling Override schedules at runtime via config listeners or environment variables.
Alternative Schedulers For modern Laravel, replace with:
How can I help you explore Laravel packages today?