{"id":19136920,"url":"https://github.com/xactsystems/command-scheduler","last_synced_at":"2026-01-08T08:08:26.659Z","repository":{"id":40535815,"uuid":"279295662","full_name":"XactSystems/command-scheduler","owner":"XactSystems","description":"Symfony Job Scheduler bundle","archived":false,"fork":false,"pushed_at":"2024-09-20T16:33:56.000Z","size":1097,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-31T02:34:11.504Z","etag":null,"topics":["command-scheduler","cron","cron-expression","hacktoberfest","job-scheduling","scheduler","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XactSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-13T12:24:37.000Z","updated_at":"2024-09-09T16:33:25.000Z","dependencies_parsed_at":"2022-07-27T09:22:32.867Z","dependency_job_id":"f9efdd3c-0290-40c7-aa7f-c48d369bae81","html_url":"https://github.com/XactSystems/command-scheduler","commit_stats":{"total_commits":92,"total_committers":2,"mean_commits":46.0,"dds":0.2717391304347826,"last_synced_commit":"d13b09fa8a4b6df01e333bd75cce9cbc89a8f80a"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XactSystems%2Fcommand-scheduler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XactSystems%2Fcommand-scheduler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XactSystems%2Fcommand-scheduler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XactSystems%2Fcommand-scheduler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XactSystems","download_url":"https://codeload.github.com/XactSystems/command-scheduler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249664075,"owners_count":21308084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-scheduler","cron","cron-expression","hacktoberfest","job-scheduling","scheduler","symfony"],"created_at":"2024-11-09T06:35:50.940Z","updated_at":"2026-01-08T08:08:26.654Z","avatar_url":"https://github.com/XactSystems.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"XactCommandScheduler\n===============\n\nThis bundle allows you to provide job scheduling via a list of jobs configured within a DBAL store.\n\nJobs can be created for once-only jobs as well as repeating jobs based on a cron expression. The bundle features an admin interface for management of the scheduled commands as well as via the CommandScheduler class.\n\nDocumentation\n-------------\n### 1) Add XactCommandScheduler to your project\n\n```bash\ncomposer require xactsystems/command-scheduler\n```\n\n### 2) Create the scheduler table\n```bash\nphp bin/console doctrine:schema:create\n```\n\n### 3) Add the routes for the scheduler admin views\nconfig/routes.yaml\n```yaml\ncommand_scheduler:\n    resource: \"@XactCommandSchedulerBundle/Resources/config/routing.yaml\"\n```\n\n### 4) Use the admin views\nBrowse to http://my-project/command-scheduler/list\n\n\n### 5) Run the command scheduler\n```bash\nphp bin/console xact:command-scheduler\n```\n\nThe command accepts the following options:\n* `--max-runtime=nnn`       Sets the maximum length in seconds the scheduler will run for. 0 (default) runs forever.\n* `--idle-time=nnn`           Sets the number of seconds the scheduler sleeps for when the command queue is empty. Defaults to 5.\n\nManage the scheduler via code\n-----------------------------\n\n### Add a scheduled command\n```php\nuse Xact\\CommandScheduler\\Scheduler\\CommandScheduler;\nuse Xact\\CommandScheduler\\Entity\\ScheduledCommand;\nuse Cron\\CronExpression;\n...\n\npublic function myControllerAction(CommandScheduler $scheduler)\n{\n    $scheduledCommand = new ScheduledCommand();\n    $scheduledCommand-\u003esetDescription('My daily command');\n    $scheduledCommand-\u003esetCommand( 'app:my-daily-command' );\n    $scheduledCommand-\u003esetCronExpression( CronExpression::factory('@daily') );\n    $scheduledCommand-\u003esetPriority(5);  // Defaults to 1\n    $scheduler-\u003eadd( $scheduledCommand );\n}\n```\n\n### Disable a command\n```php\nuse Xact\\CommandScheduler\\Scheduler\\CommandScheduler;\nuse Xact\\CommandScheduler\\Entity\\ScheduledCommand;\n...\n\npublic function myControllerAction(int $commandId, CommandScheduler $scheduler)\n{\n    $scheduler-\u003edisable($commandId);\n}\n```\n\n### Run a command immediately\n```php\nuse Xact\\CommandScheduler\\Scheduler\\CommandScheduler;\nuse Xact\\CommandScheduler\\Entity\\ScheduledCommand;\n...\n\npublic function myControllerAction(int $commandId, CommandScheduler $scheduler)\n{\n    $scheduler-\u003erunImmediately($commandId);\n}\n```\n\n### Delete a command\n```php\nuse Xact\\CommandScheduler\\Scheduler\\CommandScheduler;\nuse Xact\\CommandScheduler\\Entity\\ScheduledCommand;\n...\n\npublic function myControllerAction(int $commandId, CommandScheduler $scheduler)\n{\n    $scheduler-\u003edelete($commandId);\n}\n```\n\n### Get a list of active commands\n```php\nuse Xact\\CommandScheduler\\Scheduler\\CommandScheduler;\nuse Xact\\CommandScheduler\\Entity\\ScheduledCommand;\n...\n\npublic function myControllerAction(CommandScheduler $scheduler)\n{\n    $commands = $scheduler-\u003egetActive();\n    foreach ($commands as $command) {\n        ...\n    }\n}\n```\n\n### Creating commands via the CommandSchedulerFactory\nWhen using the factory, you can set the the configuration values for the following command settings:\n```yaml\n#config/bundles/xact_command_scheduler.yml\n\nxact_command_scheduler:\n    clear_data: ~          # Defaults to true\n    retry_on_fail: ~       # Defaults to false\n    retry_delay: ~         # Defaults to 60\n    retry_max_attempts: ~  # Defaults to 60\n```\n\nYou can then use the factory methods to create your scheduled commands.\nThe configured parameters above will be set on commands created via factory methods unless overwritten in the method calls:\n```php\nuse Xact\\CommandScheduler\\CommandSchedulerFactory;\n\nclass MyController extends AbstractController\n{\n    private CommandSchedulerFactory $commandFactory;\n\n    public function __controller(CommandSchedulerFactory $commandFactory) {\n        $this-\u003ecommandFactory = $commandFactory;\n    }\n\n    public function myEmailAction(EntityManagerInterface $em) {\n        $myLargeDataObject = 'Some enormous serialized value you want to store in the command and probably delete once the command is complete.';\n        $command = $this-\u003ecommandFactory-\u003ecreateImmediateCommand(\n            'My test command',\n            'app:test-command',\n            null,\n            $myLargeDataObject,\n        );\n        $em-\u003epersist($command);\n        $em-\u003eflush();\n    }\n}\n```\n\n#### Factory methods:\n```php\n    /**\n     * Create a command to run immediately\n     *\n     * @param string[]|null $arguments\n     * @param bool|null $clearData If null, the configuration value 'clear_data' is used. Default true.\n     * @param bool|null $retryOnFail If null, the configuration value 'retry_on_fail' is used. Default false.\n     * @param int|null $retryDelay If null, the configuration value 'retry_delay' is used. Default 60.\n     * @param int|null $retryMaxAttempts If null, the configuration value 'retry_max_attempts' is used. Default 60.\n     */\n    public function createImmediateCommand(\n        string $description,\n        string $command,\n        ?array $arguments = null,\n        ?string $data = null,\n        ?bool $clearData = null,\n        ?bool $retryOnFail = null,\n        ?int $retryDelay = null,\n        ?int $retryMaxAttempts = null\n    ): ScheduledCommand {}\n\n    /**\n     * Create a command scheduled by a CRON expression\n     *\n     * @param string[]|null $arguments\n     * @param bool|null $clearData If null, the configuration value 'clear_data' is used. Default true.\n     * @param bool|null $retryOnFail If null, the configuration value 'retry_on_fail' is used. Default false.\n     * @param int|null $retryDelay If null, the configuration value 'retry_delay' is used. Default 60.\n     * @param int|null $retryMaxAttempts If null, the configuration value 'retry_max_attempts' is used. Default 60.\n     */\n    public function createCronCommand(\n        string $cronExpression,\n        string $description,\n        string $command,\n        ?array $arguments = null,\n        ?string $data = null,\n        ?bool $clearData = null,\n        ?bool $retryOnFail = null,\n        ?int $retryDelay = null,\n        ?int $retryMaxAttempts = null\n    ): ScheduledCommand {}\n```\n\n\nCron notes\n----------\nThe bundle uses dragonmantank/cron-expression CronExpression class to determine run times and you can use the non-standard pre-defined scheduling definitions. See [Cron Format](https://en.wikipedia.org/wiki/Cron#Format) for more details.\n\nCredits\n-------\n\n* Ian Foulds as the creator of this package.\n* Piotr Nowak (https://github.com/noofaq) for inspiration when trying to find a replacement for jms/job-queue-bundle - https://github.com/schmittjoh/JMSJobQueueBundle/issues/208#issuecomment-393069592.\n* Julien Guyon (https://github.com/j-guyon) for inspiration with his command scheduler bundle.\n\nLicense\n-------\n\nThis bundle is released under the MIT license. See the complete license in the\nbundle:\n\n[LICENSE](https://github.com/xactsystems/command-scheduler/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxactsystems%2Fcommand-scheduler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxactsystems%2Fcommand-scheduler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxactsystems%2Fcommand-scheduler/lists"}