Download the PHP package azaharizaman/nexus-scheduler without Composer
On this page you can find all versions of the php package azaharizaman/nexus-scheduler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download azaharizaman/nexus-scheduler
More information about azaharizaman/nexus-scheduler
Files in azaharizaman/nexus-scheduler
Package nexus-scheduler
Short Description Framework-agnostic job scheduling engine for managing future-dated instructions with handler-based execution
License MIT
Informations about the package nexus-scheduler
Nexus\Scheduler
A framework-agnostic job scheduling engine that manages future-dated instructions through contracts, delegating execution to domain packages and persistence to the application layer.
Overview
The Nexus\Scheduler package serves as the central repository for future-dated instructions. It manages when an action should happen, but delegates what the action is (domain logic) and how the action is executed (job runner/queue).
Core Principles
- Complete Decoupling: Stateless design with all persistence via
ScheduleRepositoryInterface - Execution Agnostic: Unaware of runtime environment (Laravel Queue, pure Cron, etc.)
- Handler-Based: Domain packages implement
JobHandlerInterfacefor their specific job types - Time Control: Testable via
ClockInterfaceinjection - Hybrid Retry: Handlers signal intent, engine manages execution
Architecture
The Scheduling Paradigm
Execution Flow
-
Scheduling Phase (Domain → Scheduler)
- Domain package calls
$scheduler->schedule(ScheduleDefinition) ScheduleManagercreatesScheduledJobvalue object- Persists via
ScheduleRepositoryInterface
- Domain package calls
-
Execution Phase (Cron → Queue → Handler)
- External cron job calls
ProcessScheduledJobscommand - Command retrieves due jobs via
$manager->getDueJobs() - For each job, dispatches to queue via
JobQueueInterface - Queue worker invokes appropriate
JobHandlerInterface::handle() - Handler returns
JobResultwith retry intent ExecutionEngineupdates status and re-queues if needed
- External cron job calls
- Retry Strategy (Hybrid Delegation)
- Handler decides: "Should retry? Custom delay?"
- Engine executes: Status update, queue dispatch, exponential backoff
- Clean separation: Domain logic (intent) vs. Infrastructure (mechanism)
Installation
1. Install Package
2. Optional: Install Cron Expression Support
3. Implement Required Contracts in Your Application
4. Bind Interfaces in Service Provider
Usage
1. Schedule a Job
2. Implement a Job Handler
3. Register Handler (Tagged Service)
4. Process Scheduled Jobs (Cron)
Add to your cron:
Handler Registration Pattern
The package uses tagged services for handler discovery, avoiding tight coupling to concrete domain classes.
Domain Package Responsibility
- Implement
JobHandlerInterface - Tag in service provider:
$app->tag([YourHandler::class], 'scheduler.handlers')
Scheduler Package Responsibility
- Receive
iterable $handlersvia constructor injection - Build internal
JobType => HandlerInterfacemapping - Dispatch to appropriate handler based on job type
Zero coupling: The scheduler never knows concrete handler class names.
Retry Strategy
Hybrid Delegation Model
Handler (Domain Logic): Decides retry intent
ExecutionEngine (Infrastructure): Manages retry mechanism
- Updates job status (
FAILED→PENDING) - Increments
retry_count - Dispatches to queue with specified delay
- Applies exponential backoff if no custom delay
- Marks as
FAILED_PERMANENTifshouldRetry === false
Decision Flowchart
Value Objects
ScheduledJob
Immutable representation of a scheduled job with business logic methods:
ScheduleRecurrence
Defines repetition rules:
JobResult
Handler's response with retry intent:
Enums
JobType
Extensible enum for domain-specific job types:
JobStatus
Lifecycle state with transition validation:
Testing
Time Control
Use ClockInterface for deterministic testing:
Running the Package Test Suite
The Scheduler package now ships with a dedicated PHPUnit 11 smoke suite plus deterministic in-memory adapters under tests/Support/. Run it locally before contributing new functionality:
What the suite covers today:
ScheduleManagerTestvalidates successful dispatch, permanent-failure handling, and recurring job rollover.- Support doubles (
MutableClock,InMemoryScheduleRepository,TrackingJobQueue,CallbackJobHandler) keep tests framework-agnostic.
Future work will extend coverage across value objects, the recurrence engine, and execution engine edge cases. Contributions should include corresponding tests that reuse the provided adapters or add new deterministic doubles inside tests/Support/.
Future Features (v2)
Calendar Export
The CalendarExporterInterface is defined but bound to NullCalendarExporter (throws FeatureNotImplementedException) in v1.
Planned v2 features:
- Generate iCal files for scheduled jobs
- Google Calendar URL generation
- Outlook integration
📖 Documentation
Package Documentation
- Getting Started Guide
- API Reference
- Integration Guide
- Basic Usage Example
- Advanced Usage Example
Additional Resources
IMPLEMENTATION_SUMMARY.md- Implementation progressREQUIREMENTS.md- RequirementsTEST_SUITE_SUMMARY.md- TestsVALUATION_MATRIX.md- Valuation
License
MIT License - see LICENSE file for details.
Support
For issues, questions, or contributions, please refer to the main Nexus ERP repository.