PHPackages                             monkeyscloud/monkeyslegion-schedule - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. monkeyscloud/monkeyslegion-schedule

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

monkeyscloud/monkeyslegion-schedule
===================================

1.0.0(2mo ago)1867↑2500%1MITPHPPHP ^8.4

Since Mar 4Pushed 2mo agoCompare

[ Source](https://github.com/MonkeysCloud/MonkeysLegion-Schedule)[ Packagist](https://packagist.org/packages/monkeyscloud/monkeyslegion-schedule)[ RSS](/packages/monkeyscloud-monkeyslegion-schedule/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (2)Used By (1)

MonkeysLegion Schedule
======================

[](#monkeyslegion-schedule)

> A high-performance, modular task scheduling ecosystem for PHP 8.4+.

[![Latest Version](https://camo.githubusercontent.com/746a37f65db31cd284ed14bc5fbe55047764fc28fbf438309d7ff516ff7fb5c4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d6465762d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/monkeyscloud/monkeyslegion-schedule)[![PHP Version](https://camo.githubusercontent.com/5c4fde178293808fc8e069ac46368595f4a50dad93e207e18ec9e360d9e08a69/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e342d3737376262342e7376673f7374796c653d666c61742d737175617265)](https://php.net)[![License](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

---

✨ Overview
----------

[](#-overview)

**MonkeysLegion Schedule** is a modern scheduling engine designed for high reactivity and developer happiness. It bridges the gap between traditional Crontab one-shots and modern reactive daemons, supporting both **Attribute-based Discovery** and a **Fluent API**.

### 🚀 Key Features

[](#-key-features)

- 🧩 **Hybrid Discovery**: Automatic class-scanning via Attributes or manual registration via Service Providers.
- ⚡ **High Reactivity**: Support for **Sub-Minute (Second-Level)** precision.
- 👹 **Daemon Mode**: A persistent worker loop that polls for "pushed" ad-hoc tasks.
- 🧵 **Multi-Process execution**: Task isolation using `proc_open` to prevent bottlenecks.
- 📡 **Lifecycle Events**: Global event dispatching and per-task fluent callbacks (`onStart`, `onSuccess`, etc.).
- 📦 **Driver Agnostic**: State persistence and task queuing via **Redis** or **Cache**.

---

🛠 Installation
--------------

[](#-installation)

```
composer require monkeyscloud/monkeyslegion-schedule
```

---

📖 Core Concepts
---------------

[](#-core-concepts)

### 1. Task Registration

[](#1-task-registration)

#### **Attribute-Based (Declarative)**

[](#attribute-based-declarative)

Just add the `#[Scheduled]` attribute to any class with an `__invoke` method or to specific class methods.

```
use MonkeysLegion\Schedule\Attributes\Scheduled;

#[Scheduled(expression: '* * * * * *')] // Second-precision!
class HeartbeatAction
{
    public function __invoke()
    {
        // Runs every second
    }
}
```

#### **Manual Registration (Dynamic)**

[](#manual-registration-dynamic)

Ideal for Closures or raw CLI commands registered inside your Service Providers.

```
$schedule->command('report:generate --daily')->dailyAt('00:00');

$schedule->call(function() {
    return "Pulse sent.";
})->everyFiveMinutes();
```

### 2. Execution Modes

[](#2-execution-modes)

ModeCommandFrequencyBest For**Normal**`php ml schedule:run`Run once per executionStandard system maintenance.**Daemon**`php ml schedule:work`Continuous (1s Pulse)Real-time tasks &amp; Ad-hoc pushed jobs.---

🎮 CLI Command Palette
---------------------

[](#-cli-command-palette)

CommandDescription`schedule:run`**The Heartbeat.** Execute all tasks that are currently due.`schedule:work`**The Daemon.** Persistent loop with 1s pulse and Redis polling.`schedule:optimize`**The Cache.** Warm up task discovery for production performance.`schedule:list`**The Dashboard.** View all registered tasks, their expressions, and next run times.`schedule:test {id}`**The Sandbox.** Manually trigger a specific task for debugging.`schedule:clear-locks`**The Eraser.** Clear all task locks or a specific task lock.---

🔔 Events &amp; Callbacks
------------------------

[](#-events--callbacks)

Monitor your ecosystem with high-level dispatcher events or task-specific hooks.

- **System Events**: `TaskStarting`, `TaskFinished`, `TaskFailed`.
- **Fluent Hooks**: `->onStart()`, `->onSuccess()`, `->onFailure()`, `->after()`.

Tip

Check the full [Events Documentation](docs/events.md) for custom event object overrides and metadata handling.

---

🗺 Roadmap
---------

[](#-roadmap)

### Phase 4: Atomic Locking (Prevention) ✅

[](#phase-4-atomic-locking-prevention-)

- **LockProvider**: Interfacing with Redis/Cache for distributed locking.
- **Overlapping Prevention**: `->withoutOverlapping()` logic to ensure task exclusivity.
- **Self-Healing**: TTL-based lock expiry for automatic cleanup of stale locks.

### Completed Milestones ✅

[](#completed-milestones-)

- **Core Architecture**: Task Value Objects and the Registry.
- **Discovery Engine**: Attribute scanning and dynamic loading.
- **Sub-Minute Precision**: 6-segment Cron support.
- **Multi-Process isolation**: Non-blocking task execution.
- **Redis Integration**: Pushed ad-hoc task support via Redis drivers.
- **Logger &amp; Monitoring**: Seamless `monkeyslegion/logger` integration.
- **Atomic Locking**: Fully implemented overlapping prevention via `LockProvider`.

---

🤝 Contributing
--------------

[](#-contributing)

We welcome monkeys from all forests! Please read our [Contributing Guide](CONTRIBUTING.md) before submitting PRs.

---

⚖️ License
----------

[](#️-license)

Developed by the **MonkeysCloud Team**. Released under the [MIT License](LICENSE).

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance93

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

65d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/51e4df19377776baa8eafb605d9e7d2374b855c686f552c20d6856e94e3597c3?d=identicon)[yorchperaza](/maintainers/yorchperaza)

---

Top Contributors

[![Amanar-Marouane](https://avatars.githubusercontent.com/u/155680356?v=4)](https://github.com/Amanar-Marouane "Amanar-Marouane (6 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/monkeyscloud-monkeyslegion-schedule/health.svg)

```
[![Health](https://phpackages.com/badges/monkeyscloud-monkeyslegion-schedule/health.svg)](https://phpackages.com/packages/monkeyscloud-monkeyslegion-schedule)
```

###  Alternatives

[peppeocchi/php-cron-scheduler

PHP Cron Job Scheduler

8282.5M34](/packages/peppeocchi-php-cron-scheduler)[butschster/cron-expression-generator

Cron expression generator

511.4M2](/packages/butschster-cron-expression-generator)[elements/process-manager-bundle

The Process Manager allows you to manage (define,execute...) arbitrary processes/commands in the Pimcore backend.

49633.0k5](/packages/elements-process-manager-bundle)[pimcore/data-importer

Adds a comprehensive import functionality to Pimcore Datahub

44763.4k2](/packages/pimcore-data-importer)[rewieer/taskschedulerbundle

Task Scheduler with CRON for Symfony

63242.1k](/packages/rewieer-taskschedulerbundle)[silverstripe/crontask

Module for running tasks with a standard cron timeschedule

24754.1k25](/packages/silverstripe-crontask)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
