Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cron Bundle Laravel Package

bigfoot/cron-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. 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.

  2. 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
            ],
        ],
    ];
    
  3. 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
    

Implementation Patterns

Workflow: Job Definition & Scheduling

  1. Command-Based Jobs

    • Create Artisan commands for reusable cron tasks (e.g., SendReportsCommand).
    • Reference them in config/bigfoot_cron.php with cron syntax:
      'jobs' => [
          'send_reports' => [
              'command' => 'reports:send',
              'schedule' => '0 3 * * *', // Daily at 3 AM
          ],
      ],
      
  2. 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
    
  3. Logging & Output Redirect command output to a log file for debugging:

    'command' => 'app:cleanup >> /var/log/cron/cleanup.log 2>&1',
    

Integration Tips

  • Laravel-Specific: Use Laravel’s Artisan::call() in commands to leverage queues/jobs internally.
  • Symfony Compatibility: If using Laravel’s Symfony bridge, ensure the bundle’s event listeners (e.g., CronEvent) are properly wired.
  • Docker/Serverless: For containerized setups, mount logs and use cron via crontab -e with the bundle’s generated commands.

Gotchas and Tips

Pitfalls

  1. Deprecated Symfony 2.x

    • The bundle targets Symfony 2.x (2014). For Laravel 5.8+, use spatie/scheduler or laravel-schedule instead.
    • Workaround: Fork the repo and update dependencies if critical features are needed.
  2. Cron Syntax Errors

    • Validate schedules with crontab.guru. Example:
      // ❌ Invalid: '0 0 * * *' (missing day-of-week)
      // ✅ Valid: '0 0 * * 0' (Sunday at midnight)
      
  3. Permission Issues

    • Ensure the user in config has execute permissions for the command:
      chmod +x artisan
      sudo -u www-data php artisan my_job
      
  4. No Built-in Queue Support

    • The bundle runs commands directly. For async tasks, wrap commands in Laravel queues or use dispatch() inside the command.

Debugging

  • Dry Runs: Test schedules locally with:
    php artisan schedule:run
    
  • Log Inspection: Check /var/log/cron.log or redirect output as shown above.
  • Bundle Events: Listen for CronEvent to log job executions:
    public function onCron(CronEvent $event) {
        Log::info("Job {$event->getJob()} executed at {$event->getTimestamp()}");
    }
    

Extension Points

  1. 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()}");
        }
    }
    
  2. Dynamic Scheduling Override schedules at runtime via config listeners or environment variables.

  3. Alternative Schedulers For modern Laravel, replace with:

    • spatie/scheduler: For Symfony/Laravel hybrid apps.
    • laravel-schedule: Native Laravel solution with queue support.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk