kdyby/datetime-provider
Kdyby/DatetimeProvider is a Nette Framework extension that registers a DateTime provider service for obtaining the current date and time. Inject it instead of creating DateTime instances directly, making time-dependent code testable, mockable, and configurable via NEON configuration.
created_at/updated_at, log correlation timestamps, and multiple domain events fired in one transaction should resolve to the same instant. Without that, ordering bugs and flaky tests appear as "sometimes" failures that are expensive to diagnose.NOASSERTION license that legal must review before it ships in a commercial product. There is no security response path and no compatibility work for modern PHP.DateTime. Modern equivalents (DateTimeImmutable, PSR-20 ClockInterface, symfony/clock, Carbon's setTestNow) cover the same ground with active maintenance.Clock interface bound as a singleton, with SystemClock and FrozenClock, plus Carbon's test helpers); you are on Symfony (PSR-20 + symfony/clock); you need sub-second precision guarantees or monotonic time for benchmarking; or your only requirement is test freezing, which the framework already solves.For executives. The idea behind this package — one injected clock per request — is worth adopting; the package itself is not. It is an eight-year-old extension for a different framework, with single-digit stars, no dependents, no maintained release, and an unclear license. The recommendation is to build the equivalent internally in about a day: a Clock interface with SystemClock and FrozenClock implementations, bound once per request. That gives us deterministic tests for billing, trials, and scheduling, consistent timestamps across a request, and one explicit answer to "what timezone are we in?" — with no third-party maintenance or licensing exposure.
For engineering. This is a Nette DI extension, so adopting it on Laravel means writing our own binding regardless; the net saving is zero. The functional surface we actually need is small: a provider returning current date, time, datetime, and timezone, with the ability to freeze and advance time in tests. We replicate that as ~100 lines behind an interface, register it as a singleton, inject it wherever now() is currently called directly, and lint against new DateTime()/Carbon::now() in domain code. Benefits: no sleep() in tests, no midnight-flake in CI, consistent audit timestamps, explicit timezone source. Costs and risks: near-zero build cost, and we avoid an unmaintained dependency with a NOASSERTION license. Credit the original design in the ADR and move on.
How can I help you explore Laravel packages today?