Download the PHP package aleblanc/simple-cron-scheduler without Composer

On this page you can find all versions of the php package aleblanc/simple-cron-scheduler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package simple-cron-scheduler

simple-cron-scheduler

Symfony bundle to orchestrate cron through a single crontab entry + a declarative schedule (PHP attributes or YAML), with subprocess isolation by default. No Messenger, no long-running daemon. MIT.

Targets Symfony 7.2 → 10, PHP 8.4+.

Everything else lives in your application code.

Why this bundle

It is an alternative to symfony/scheduler that needs neither Messenger nor Supervisor. symfony/scheduler dispatches its tasks through Messenger: you need a transport and a messenger:consume worker kept alive by a process supervisor (Supervisor, systemd…) that you deploy and monitor. simple-cron-scheduler removes all of that: the cadence comes from the OS cron (* * * * *), which wakes a fresh process every minute. No worker to keep alive, no transport, nothing to supervise — a crash has nothing to restart.

In spirit it is close to Laravel's scheduler (a single crontab line, a declarative schedule in code, @daily macros, between windows, environment restriction) — brought to Symfony with a repeatable #[AsCronTask] attribute, native shell tasks, and per-task memory isolation via subprocess on top.

symfony/scheduler simple-cron-scheduler
Long-running worker required (messenger:consume) ❌ none
Supervisor / systemd required to keep the worker alive ❌ not needed
Messenger / transport required ❌ none
Trigger the worker OS cron (* * * * *)
Memory isolation depends on the transport ✅ subprocess by default
Native shell tasks no ✅ yes

Installation (automatic, with Flex)

The package ships a Flex recipe: the quickest way is to point your app at this repo as a custom recipe endpoint, then require the package — the bundle and config are wired automatically.

1. Add the recipe endpoint to your app's composer.json:

2. Require the package — the recipe runs on install:

This registers the bundle in config/bundles.php, creates config/packages/simple_cron_scheduler.yaml, and prints a post-install reminder. The bundle's configuration alias is simple_cron_scheduler.

3. Add the single crontab entry on the server (the only manual step — Flex does not touch the crontab):

That's it — no worker, no Supervisor. Check your tasks with php bin/console scheduler:run --list.

Without the recipe (or before tagging a release), do it by hand: add SimpleCronScheduler\SimpleCronSchedulerBundle::class => ['all' => true] to config/bundles.php, create config/packages/simple_cron_scheduler.yaml (a minimal simple_cron_scheduler: { timezone: Europe/Paris } is enough), then add the crontab line. Recipe details: recipes/README.md.

Declaring tasks with an attribute (#[AsCronTask])

The attribute is repeatable: stack several schedules on the same command, with different arguments.

#[AsCronTask] fields

Field Type Default Description
expression string required 5-field cron or a macro (@daily, @hourly, @weekly, @monthly, @yearly).
name ?string null Unique name. Derived from the command name when absent.
description ?string null Human-readable label shown by scheduler:run --list.
args string[] [] CLI arguments passed to the command.
runner ?string null process | in_process. null = global default.
timeout ?int null Max seconds (process mode).
skipMinutes int[] [] Minutes to exclude (0–59).
skipHours int[] [] Hours to exclude (0–23).
skipDays int[] [] Weekdays to exclude (0=Sunday … 6=Saturday).
skipMonths int[] [] Months to exclude (1–12).
days int[] [] Allowlist of weekdays (0=Sunday … 6=Saturday). Empty = every day.
between [from, to] null Run ONLY within this time window.
unlessBetween [from, to] null Do NOT run within this window (handles the midnight wrap).
env string[] [] Allowed environments (%kernel.environment%). Empty = all.
when ?string null Service id of a CronCondition implementation.
group ?string null Filtering via --group.
disabled bool false Disable without removing the attribute.
lock bool true Per-task anti-overlap: skip this task if a previous run is still active.

Declaring tasks in YAML (shell / command / service)

config/packages/simple_cron_scheduler.yaml:

Each entry has exactly one of command:, shell: or service: — otherwise it fails at boot. All runtime fields (skipMinutes, skipHours, skipDays, skipMonths, days, between, unlessBetween, env, when, description, group, disabled, lock, runner, timeout) are available in YAML too:

A full example lives in doc/examples/simple_cron_scheduler.yaml.

Calendar conditions

Beyond the cron expression itself, these additive filters refine when a task runs (all of them must pass; any match on a skip* list excludes the run):

Field Excludes / restricts Values
skipMinutes minutes to skip 0–59
skipHours hours to skip 0–23
skipDays weekdays to skip 0=Sunday … 6=Saturday
skipMonths months to skip 1–12
days allowlist of weekdays (runs only on these) 0=Sunday … 6=Saturday
between / unlessBetween time-of-day window ['HH:MM', 'HH:MM']

They combine freely — e.g. days: [1..5] + skipHours: [0..5] = weekday business-hours only. When a task is ruled out, a TaskSkippedEvent is dispatched with the matching reason (skipHours, days, skipDays, skipMonths, …).

Execution modes (runners)

Global via default_runner, overridable per task via runner:.

PHP binary resolution. The process runner spawns php bin/console …. By default (no php_binary config) the binary is resolved at runtime via PhpExecutableFinder, which uses the PHP currently running scheduler:run — so it works the same on macOS (Symfony CLI), in Docker, and on the server, even when var/cache/ is shared between host and container. Pin it explicitly only if you need to: php_binary: '/usr/bin/php'.

when conditions

Create a service implementing CronCondition (auto-tagged — no config needed):

Reference it by its service id (= FQCN with default autowiring):

Observability — events

Each run dispatches Symfony events. Wire your own listeners (alerts, email, metrics):

Event When Payload
TaskStartingEvent before execution task, now
TaskFinishedEvent after execution (success or failure) task, result
TaskFailedEvent exit ≠ 0 or exception task, result, exception
TaskSkippedEvent task ruled out by a condition task, reason

Example — email the output on failure (Laravel's emailOutputOnFailure equivalent):

Logging

Each finished/failed task is logged on a dedicated Monolog channel (log_channel, default scheduler) — the bundle declares the channel to MonologBundle automatically, so you can route it to its own file without touching the bundle:

Rename the channel via config if you prefer:

If MonologBundle is not installed, logging is silently skipped (the command falls back to a null logger) — the bundle stays fully usable.

Anti-overlap

Overlap is handled per task, not globally — so a single slow task can never block the others.

Optional belt-and-suspenders at the crontab level for slow Symfony boots (only if you set lock_runner: true):

Commands

Command Role
scheduler:run Crontab entry — runs the tasks that are due. Always returns 0.
scheduler:run --list List all tasks (name, expression, type, description).
scheduler:run --dry-run Show what would run without executing.
scheduler:run --only=NAME Run only the named task.
scheduler:run --group=G Run only the tasks of that group.
scheduler:list Alias of scheduler:run --list.

Add -v to stream subprocess output live, line by line, prefixed with the task name ([task-name] …) — useful for long-running tasks where Process would otherwise buffer everything and only return at the end (looking like a hang). -v also prints task -> starting / task -> exit N (Xms) markers.

Tests & quality

Configs: phpstan.dist.neon (level 8, src + tests) and .php-cs-fixer.dist.php.

License

MIT


All versions of simple-cron-scheduler with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
dragonmantank/cron-expression Version ^3.4
psr/log Version ^3.0
symfony/config Version ^7.2|^8.0|^9.0|^10.0
symfony/console Version ^7.2|^8.0|^9.0|^10.0
symfony/dependency-injection Version ^7.2|^8.0|^9.0|^10.0
symfony/event-dispatcher Version ^7.2|^8.0|^9.0|^10.0
symfony/http-kernel Version ^7.2|^8.0|^9.0|^10.0
symfony/lock Version ^7.2|^8.0|^9.0|^10.0
symfony/process Version ^7.2|^8.0|^9.0|^10.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aleblanc/simple-cron-scheduler contains the following files

Loading the files please wait ...