Download the PHP package componenta/clock without Composer
On this page you can find all versions of the php package componenta/clock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download componenta/clock
More information about componenta/clock
Files in componenta/clock
Package clock
Short Description PSR-20 clock integration for Componenta
License MIT
Informations about the package clock
Componenta Clock
PSR-20 clock and datetime factory abstractions for deterministic time handling.
Installation
The package declares Componenta\Clock\ConfigProvider in extra.componenta.config-providers.
When componenta/composer-plugin is installed, the provider is added to the generated provider list automatically.
Requirements
- PHP 8.4+
psr/clock
Related Packages
| Package | Why it matters here |
|---|---|
psr/clock |
Defines ClockInterface for domain and application code. |
componenta/di |
Registers ClockInterface and DateTimeFactoryInterface through ConfigProvider. |
componenta/cqrs |
Commands and handlers can depend on clocks instead of constructing time directly. |
componenta/session |
Can use time for TTL, activity, and expiration logic. |
What It Provides
Clock: minimal UTC PSR-20 clock.DateTimeFactoryInterface: PSR-20 clock plus date creation methods.DateTimeFactory: production datetime factory with timezone support.FrozenClock: deterministic test clock and factory.- Typed exceptions for invalid timezones and datetime parsing failures.
DateTimeFactory
The configured timezone is exposed as a read-only property:
Change timezone immutably:
withTimezone() returns the same instance when the requested timezone is already active.
FrozenClock
Use FrozenClock in tests or deterministic workflows.
DI Registration
ConfigProvider registers:
DateTimeFactory::classfactoryPsr\Clock\ClockInterfacealias toDateTimeFactoryInterfaceDateTimeFactoryInterfacealias toDateTimeFactory
All versions of clock with dependencies
ext-mbstring Version *
componenta/config Version ^3.0.0
psr/clock Version ^1.0