Weave Code
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

Command Scheduler Bundle Laravel Package

dukecity/command-scheduler-bundle

Symfony bundle to schedule console commands with cron expressions. Manage native and custom commands, backed by database storage and optional Doctrine migrations. Supports modern PHP/Symfony versions; see wiki for configuration, execution, and upgrade notes.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony Native Integration: The bundle is designed for Symfony applications, leveraging Symfony’s console command system (Console\CommandLoader) and Doctrine ORM for persistence. This aligns well with Symfony’s ecosystem, reducing friction for teams already using these components.
  • Cron-Like Scheduling: Mimics Unix crontab syntax, which is familiar to developers managing scheduled tasks. The use of cron expressions (* * * * * *) provides flexibility for time-based triggers.
  • Extensible Entity Design: The BaseScheduledCommand and ScheduledCommandInterface allow customization (e.g., adding metadata like customField), enabling domain-specific extensions without forking the bundle.
  • Event-Driven Architecture: Emits events (SchedulerCommandFailedEvent) for failed executions, enabling integration with monitoring/logging systems (e.g., Sentry, ELK).

Integration Feasibility

  • Symfony Version Lock: Requires Symfony 8.0+ and PHP 8.4+ (for v7.x). If the project uses older versions, downgrading to v6.x (Symfony 7.0+) is possible but may introduce maintenance overhead.
  • Doctrine Dependency: Relies on Doctrine ORM for storage. Projects using Eloquent (Laravel) or other ORMs would need a wrapper layer or migration.
  • Console Command Discovery: Uses Symfony’s CommandLoader to auto-discover commands, reducing manual configuration. Non-Symfony console commands (e.g., custom CLI tools) would require explicit registration.
  • Web UI: Provides a /command-scheduler admin interface (requires ROLE_ADMIN). Useful for non-technical stakeholders but adds a frontend dependency (Bootstrap 5).

Technical Risk

  • Database Schema Changes: Requires migrations (make:migration, doctrine:migrations:migrate) and may conflict with existing schemas if not carefully managed.
  • Performance at Scale: Cron expressions are evaluated on every request if the scheduler runs in-process (e.g., via Symfony’s CronExpression). For high-frequency schedules, consider a dedicated queue (e.g., Symfony Messenger + cron) to offload execution.
  • Concurrency Issues: No built-in locking mechanism for overlapping command executions. Risk of race conditions if commands modify shared resources (e.g., database).
  • Error Handling: Failed commands trigger events but lack built-in retry logic or dead-letter queues. Custom logic (e.g., exponential backoff) would be needed for resilience.
  • Testing Complexity: Scheduling logic requires time-based tests (e.g., mocking DateTime). Test coverage may need expansion for edge cases (e.g., DST transitions).

Key Questions

  1. Execution Environment:
    • Will commands run in-process (Symfony HTTP kernel) or via a separate cron daemon? The latter may require custom integration (e.g., exec() calls).
  2. Scaling Needs:
    • How many scheduled commands are anticipated? For >1000 commands, consider a distributed task queue (e.g., RabbitMQ, AWS SQS).
  3. Monitoring:
    • Are there existing observability tools (e.g., Prometheus, Datadog) to track command success/failure metrics?
  4. Security:
    • Is ROLE_ADMIN the correct access control for scheduling? May need RBAC adjustments for multi-tenant apps.
  5. Custom Logic:
    • Are there use cases for pre/post-command hooks (e.g., logging, notifications)? The bundle’s event system could be extended.
  6. Legacy Support:
    • If using Symfony <8.0, is v6.x’s maintenance status (last release 2026-02-09) acceptable, or should a fork be considered?

Integration Approach

Stack Fit

  • Symfony Ecosystem: Ideal for Symfony applications using Doctrine ORM and console commands. Minimal additional dependencies beyond the bundle itself.
  • PHP Extensions: No special extensions required beyond standard Symfony/PHP dependencies (e.g., pdo, intl for cron parsing).
  • Frontend: Uses Bootstrap 5 for the admin UI. Ensure compatibility with the project’s frontend stack (e.g., Tailwind, Vue).
  • Alternatives Considered:
    • Laravel: No native support; would require wrapping cron expressions in a Laravel-specific service.
    • Queue Systems: For high-scale needs, consider Symfony Messenger + cron triggers instead of direct DB polling.

Migration Path

  1. Assessment Phase:
    • Audit existing scheduled tasks (cron jobs, at, or manual scripts) to identify candidates for migration.
    • Document dependencies (e.g., environment variables, shared libraries) for each command.
  2. Setup:
    • Enable Symfony Flex contrib recipes:
      composer config extra.symfony.allow-contrib true
      composer require dukecity/command-scheduler-bundle
      
    • Configure security (add ROLE_ADMIN route protection).
  3. Database:
    • Run migrations:
      php bin/console make:migration
      php bin/console doctrine:migrations:migrate
      
    • For existing cron jobs, export schedules to the new system (e.g., via a one-time script).
  4. Command Registration:
    • Verify all target commands are auto-discovered. For custom commands, ensure they’re properly tagged or registered in the container.
  5. Testing:
    • Write integration tests for critical schedules using CronExpression assertions (e.g., assertTrue($expression->isDue())).
    • Test edge cases: DST transitions, leap seconds, and overlapping executions.

Compatibility

  • Symfony Components: Compatible with Symfony 8.0+ core components (Console, Doctrine, Security). Test with the exact Symfony version in use.
  • Doctrine: Supports Doctrine ORM 3.x. Ensure the project’s Doctrine configuration (e.g., doctrine/dbal, doctrine/orm) matches the bundle’s requirements.
  • PHP Extensions: Cron parsing relies on PHP’s DateTime and Intl (for locale-aware expressions). Verify these are enabled.
  • Legacy Systems: If migrating from legacy cron, handle differences in:
    • Environment variables (e.g., APP_ENV vs. shell variables).
    • Output handling (cron emails vs. Symfony’s logger).

Sequencing

  1. Phase 1: Pilot:
    • Migrate 2–3 low-risk commands to validate the bundle’s behavior.
    • Monitor for issues (e.g., command failures, performance bottlenecks).
  2. Phase 2: Full Rollout:
    • Replace remaining cron jobs with the bundle.
    • Deprecate old cron entries and set up alerts for missed executions.
  3. Phase 3: Optimization:
    • Adjust cron expressions for precision (e.g., use * * * * * * for seconds granularity).
    • Implement custom fields (e.g., priority, timeout) via entity extension.
  4. Phase 4: Monitoring:
    • Integrate with existing monitoring (e.g., log failed events to ELK).
    • Set up alerts for repeated failures or long-running commands.

Operational Impact

Maintenance

  • Bundle Updates: Follow the changelog for breaking changes (e.g., Symfony 8.0+ requirements in v7.x). Test updates in a staging environment.
  • Custom Entity Maintenance: If extending BaseScheduledCommand, ensure migrations are run for new fields and validate backward compatibility.
  • Dependency Management: Monitor for updates to Symfony/Doctrine that may affect the bundle (e.g., deprecations in Doctrine ORM 3.x).

Support

  • Troubleshooting:
    • Command Failures: Check SchedulerCommandFailedEvent logs and the admin UI for errors.
    • Missing Commands: Verify commands are auto-discovered (debug with bin/console debug:command).
    • Cron Syntax: Use tools like crontab.guru to validate expressions.
  • Community: Limited activity (25 stars, last release 2026-02-09). Consider contributing fixes or forking if critical issues arise.
  • Documentation: Wiki and README are comprehensive but may lack real-world examples (e.g., handling command dependencies).

Scaling

  • Horizontal Scaling:
    • In-Process Execution: Running schedules in the Symfony process scales poorly with many commands. Consider:
      • Dedicated Worker: Use a separate PHP process (e.g., supervisord) to run schedules.
      • Queue-Based: Offload to Symfony Messenger + cron (e.g., trigger a message every minute, process in workers).
    • Database Load: Frequent isDue() checks may stress the DB. Optimize with:
      • Indexes on scheduled_at and status fields.
      • Batch processing for high-volume schedules.
  • Vertical Scaling:
    • Increase PHP workers (e.g., pcntl_fork) for parallel command execution, but monitor resource usage.

Failure Modes

Failure Scenario Impact Mitigation
Database downtime Missed schedules
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.
graham-campbell/flysystem
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi