sifex/sla-timer
Sifex SLA Timer helps Laravel apps manage service-level agreements with timers that track elapsed and remaining time, pause and resume as needed, and check for breaches. Attach timers to Eloquent models and query active, paused, or expired SLAs through a simple API.
What this package is: a business-hours / SLA duration calculator for Laravel — schedule definitions (from('22:00:00')->to('02:00:00')), weekly agendas, pauses and holidays, and breach evaluation. It answers "how much SLA clock elapsed between A and B, excluding non-covered time."
Architecture fit: Strong for any Laravel service that owns SLA timers — ticket/incident management, contract entitlement, support desk, order fulfilment. It is a pure computation library (Carbon + Collections only), so it slots in as a domain dependency with no infrastructure footprint: no queue worker, no storage, no external service. It is not a scheduler, a persistence layer, or a breach-notification system — those remain ours. That is the right boundary, but it means the surrounding machinery (storing clock state, running breach sweeps, auditing) is our build, not theirs.
Release assessment (v0.2.0): This is a substantial, credible release. Three categories of change matter:
^8.3; Carbon ^2 → ^3; illuminate/collections ^11|^12|^13; and AgendaInterface::toPeriods() now returns start/end Carbon pairs rather than CarbonPeriod[].Integration feasibility: Feasible but gated. The Laravel 11+ and PHP 8.3+ requirements are the binding constraints — if we run Laravel 10 or PHP 8.1/8.2, this release is unreachable without a platform upgrade. Carbon 3 is a major with its own breaking surface, so this is not a drop-in patch; it is a coordinated platform move. The toPeriods() change is narrow and only bites direct consumers; teams that use the higher-level duration/breach API are likely unaffected.
Technical risk:
0.3.0 could break us again. Pin exactly and treat every bump as a review event.from/to (e.g. 09:00:00→09:00:00) now means 24/7 coverage. Any existing config that used equal times as a de facto "no coverage" or placeholder will now silently grant full coverage — an over-credit risk that no test will catch for us.Key questions for engineering:
toPeriods() directly anywhere, or only through higher-level APIs?from/to times today, and what did we intend them to mean?Stack fit: Native fit for Laravel 11/12/13 on PHP 8.3–8.5. Anything older is out of scope for this release and effectively pins us to 0.1.x, which carries the known correctness and memory bugs. That trade-off should be an explicit, recorded decision rather than an accident of inertia.
Migration path: Treat this as a platform upgrade that happens to include a package bump, not the reverse.
0.2.*, pinned exactly.Compatibility: The toPeriods() signature change is a compile-time break — cheap to detect, cheap to fix, and likely irrelevant if we consume the higher-level API. The dangerous compatibility item is behavioural, not structural: equal from/to becoming 24/7. Run an audit query over stored schedule definitions for from == to before deploying and decide each case deliberately. Also re-verify any schedule crossing midnight, since its computed coverage changes by design.
Sequencing: The performance fix makes inline calculation viable, so resist the temptation to adopt it mid-quarter on a live SLA path. Do it behind a feature flag with a shadow-mode period: compute durations both ways for a fixed window, diff the outputs, and only cut over when the deltas are explained. Given that the previous release produced silently wrong numbers, a parallel-run comparison is the cheapest possible insurance and doubles as our historical-remediation evidence.
Effort shape: Small code change, moderate platform work, non-trivial validation and data-remediation work. Budget for the last two; they are the actual project.
Maintenance: Low ongoing code maintenance — it is a dependency, not a service. The real maintenance cost is version discipline: at 0.x, pin exactly, review every changelog, and assume each minor release may break us. Assign a named owner for that review; unattended pre-1.0 dependencies drift into unplanned emergency upgrades.
Support: Support burden sits with our team, not the package, because the failure modes are ours: bad schedule config, wrong timezone, misunderstood coverage semantics. The 98.4% coverage and PHPStan level-8 cleanup in this release are meaningful signals of engineering quality and reduce the odds we are debugging someone else's arithmetic — but they do not substitute for our own contract tests.
Scaling: Transformed by this release. The quadratic-to-linear fix removes the memory ceiling that made year-long and multi-year calculations impractical. Expect this to unlock use cases previously ruled out on cost — real-time SLA clocks in request handlers, nightly multi-year recomputation, backfill of historical breaches. Capacity planning for those now shifts to wherever we store and query results, not to the calculation itself.
Failure modes to design against:
from/to now yields 24/7. Validate at authoring time and reject ambiguous schedules.Ramp-up: Low for engineers. The API is small, expressive, and reads like the domain (from()->to(), weekly agendas, pauses, holidays). The genuine ramp-up cost is conceptual, not technical: getting the team fluent in coverage semantics — overnight windows, holidays versus pauses, what a breach means — so that schedule definitions are reviewed by someone who understands the contract they encode. Pair the adoption with a short internal write-up of our schedule conventions and the equal-time rule. That document, not the library, is what prevents the next silent wrong number.
How can I help you explore Laravel packages today?