- Does kdyby/datetime-provider-bundle work with Laravel?
- No. It is a Symfony bundle built around a Symfony Bundle class and DI compiler pass, and Laravel has no bundle lifecycle for those hooks to run. Its service definitions will not be auto-discovered or registered in Laravel's container. For Laravel, use Carbon's test clock or bind a PSR-20 ClockInterface instead.
- How do I install kdyby/datetime-provider-bundle in a Laravel application?
- You can require it with Composer, but it will not integrate with Laravel out of the box. There is no Laravel service provider, facade, or config publishing, so you would have to write an adapter for a Symfony-specific package. Avoid forcing installation with ignore-platform-reqs, because that turns a clean incompatibility into a runtime risk.
- Which Laravel versions are supported by kdyby/datetime-provider-bundle?
- None are officially supported. The package targets Symfony 3 and 4-era applications with PHP 7.x assumptions, and its last release was in 2019. Modern Laravel applications are likely to hit Composer resolution conflicts rather than gain a usable feature.
- What is the Laravel equivalent of a DateTimeProvider?
- Laravel already provides deterministic time control through Carbon and the Date facade, especially Date::setTestNow() and Carbon::setTestNow(). For a framework-neutral contract, bind a PSR-20 ClockInterface as a singleton and inject it where time matters. That gives you the same injectable-now pattern without adding a second time abstraction.
- How do I freeze time in Laravel tests instead of using this bundle?
- Use Date::setTestNow() or Carbon::setTestNow() with a fixed timestamp before exercising the code under test. Reset the test clock afterward so later assertions are not affected. This is the ecosystem-standard approach in Laravel and avoids sleeping or mocking global state.
- Can I register the Kdyby DateTimeProvider services in AppServiceProvider?
- You can bind an interface to your own implementation in AppServiceProvider, but the bundle's Symfony compiler pass and service definitions will not load in Laravel. Porting the idea locally is usually simpler than adapting the Symfony bundle. Define a small clock contract with a system implementation and a frozen implementation for tests.
- Is kdyby/datetime-provider-bundle maintained and safe for production?
- It appears dormant: the last release was in December 2019, it has very few stars and no dependents, and it is maintained by a single maintainer. There is no clear security response path, and it has no production validation in the Laravel ecosystem. That fails a basic supply-chain bar for most teams.
- What license does kdyby/datetime-provider-bundle use?
- Repository metadata reports NOASSERTION, meaning the license is unresolved rather than clearly declared. That is a hard gate in many organizations and requires legal review before use. For a non-Laravel bundle with no releases since 2019, that review is rarely worth the effort.
- Should I use PSR-20 Clock or this DateTime provider bundle in Laravel?
- Prefer PSR-20 ClockInterface bound as a singleton in a service provider, using symfony/clock or a trivial in-house implementation. Inject the clock into services that need deterministic time and swap in a frozen clock in tests. This keeps one standard abstraction and avoids maintaining a parallel Symfony-oriented dependency.
- How do I refactor new DateTime calls to make time testable in Laravel?
- Inventory calls to now(), new DateTime(), and time() across the codebase, then inject a clock into the services that need controllable time. Bind the clock in a service provider and add a test helper that freezes and resets it. Refactor incrementally, starting with high-churn areas such as billing, scheduling, and expiry logic.