Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Clock Laravel Package

psr/clock

PSR-20 Clock interface for PHP. Defines ClockInterface::now() returning DateTimeImmutable, enabling dependency injection of time sources and easy testing. This package provides only the interface; use or create an implementation.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Standardizing time handling across the application to avoid hardcoding time functions (e.g., time(), DateTime), reducing bugs related to time manipulation and environment inconsistencies
  • Enabling seamless testing by allowing mock clock implementations for deterministic test scenarios without modifying production code
  • Building future-proof systems where time sources can be swapped (e.g., switching between system clock, NTP-synced clocks, or simulated time for testing) without rewriting core logic
  • Ensuring compatibility with other PSR-compliant libraries and frameworks, reducing integration friction and technical debt

When to Consider This Package

Adopt this package when your project requires abstracting time-dependent logic for testability, environment-specific configurations (e.g., staging vs. production), or integration with PSR-20-compatible dependencies. It’s ideal for long-term maintainable systems where decoupling time sources from business logic is critical. Avoid it for simple scripts with no need for testable time mocking, or if your project requires advanced time features beyond the interface’s scope (e.g., time zone manipulation), though note that implementations can extend functionality while adhering to the standard.

How to Pitch It (Stakeholders)

For executives: "This lightweight PSR standard eliminates time-related bugs and technical debt by providing a consistent way to handle time across our system. It reduces development costs by enabling easy testing and future-proofing our code against evolving time requirements, all with zero licensing risk (MIT)."
For engineering: "By adopting psr/clock, we standardize time handling across the codebase, making it trivial to mock time in tests and swap implementations (e.g., for distributed systems or time-travel debugging). It integrates seamlessly with other PSR-compliant tools, reducing integration overhead and ensuring compatibility with the broader PHP ecosystem."

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport