- How do I install rikudou/clock in a Laravel application?
- Install it with composer require rikudou/clock. The package is framework-agnostic, so integration is just registering a service provider (if one ships with the package and is not auto-discovered) and binding the clock interface to a concrete implementation in your container. There are no native extensions, external services, or queue/HTTP surfaces to configure, so the real work is refactoring call sites, not the dependency itself.
- Does rikudou/clock implement PSR-20 (Psr\Clock\ClockInterface)?
- This is not confirmed by the README and should be verified before adoption. Open the package source and check whether the interface signature matches PSR-20, specifically now(): DateTimeImmutable. If it exposes a bespoke interface instead, you would be adopting a private dialect for a problem the PHP ecosystem has already standardized.
- How do I use rikudou/clock to test time-dependent code?
- Inject the clock interface into the classes that need the current time instead of calling time(), now(), or Carbon::now() directly. In tests, bind a fixed or offset clock that returns a known instant, then assert behavior for expiry, TTL, scheduling, and rate windows. Make sure the test double can be reset between tests so state does not leak across cases.
- Is rikudou/clock safe to use in production?
- Technically the runtime risk is low because the package is a thin abstraction with no I/O or extensions. The real risk is maintenance: it has roughly 1 star, 0 dependents, and no evident release cadence, so there is no downstream usage acting as a compatibility canary. Assume you will own the code from day one and plan to fork if needed.
- What are the alternatives to rikudou/clock?
- The strongest alternative is symfony/clock, which is PSR-20 compliant, actively maintained, and ships MockClock plus ClockSensitiveTrait. A second option is depending on the PSR-20 interface and writing your own roughly 40-line SystemClock and FrozenClock, which gives zero third-party risk and full control. Adopting rikudou/clock only makes sense behind an adapter if it demonstrably implements PSR-20 and returns immutable UTC.
- Does rikudou/clock integrate with Laravel's service container and auto-discovery?
- The package is framework-agnostic, so any Laravel wiring is up to you unless it ships a provider. Check composer.json for extra.laravel.providers to confirm auto-discovery and review the illuminate/support constraint against your pinned Laravel version. Bind the clock as a singleton in a service provider if you want one shared instance per request, and document that choice because a singleton carries shared state.
- Which Laravel and PHP versions does rikudou/clock support?
- Check the composer.json constraints on php and illuminate/support to confirm compatibility with your pinned versions. Because maintainer activity is unclear and there are no dependents, a future Laravel or PHP bump could strand you on a fork. Prefer a stack baseline of Laravel 9+ and PHP 8.1+, where constructor injection is already the norm.
- Will rikudou/clock affect my tests globally, for example through Carbon::setTestNow?
- That is the failure mode to check for before adopting. A clock that internally calls Carbon::setTestNow() mutates process-global state and leaks across tests, which is exactly what the abstraction is supposed to prevent. Explicit dependency injection is safe; read the source to confirm the implementation does not hijack global time.
- Does rikudou/clock return immutable dates and handle timezones correctly?
- This is unverified from the documentation. Confirm whether now() returns DateTimeImmutable or a mutable DateTime, since mutable returns reintroduce the aliasing bugs the clock pattern is meant to eliminate. Also check whether the clock normalizes to UTC explicitly or inherits date_default_timezone_set(), and prefer explicit UTC in domain code.
- Is rikudou/clock worth adopting, or should I write my own clock abstraction?
- The package is a small surface (an interface, a system clock, a test double, and a provider) that costs roughly a day to write internally, so assess the pattern rather than the artifact. With 1 star and 0 dependents there is no community to surface breakage, and the default recommendation is not to adopt it as a runtime dependency. Use symfony/clock or an internal PSR-20 implementation, or wrap rikudou/clock behind an adapter so the package type never leaks into domain signatures.