- Is icanhazstring/symfony-time-machine a Laravel package?
- No. It is a Symfony bundle that ships a Bundle subclass, a DI extension, and a compiler pass, and it is bootstrapped through config/bundles.php and the Symfony kernel. Laravel's Illuminate\Foundation\Application has no bundle loader and cannot register a Symfony\Component\HttpKernel\Bundle\Bundle. For Laravel you can only port the concept, not install the package as-is.
- How do I install icanhazstring/symfony-time-machine?
- In a Symfony application you install it with Composer and register the bundle in config/bundles.php, ideally only for the dev and test environments. You then wire whatever clock or time service the bundle decorates. Since the repository has no 2022+ release, check that its Composer constraints match your PHP and Symfony versions before committing.
- Does Symfony Time Machine work with Laravel or only Symfony?
- It is Symfony-only. The package depends on Symfony's bundle and dependency-injection machinery, which Laravel does not provide. A Laravel team cannot integrate it without writing a shim, and at that point reimplementing the behavior with Carbon::setTestNow is simpler. The useful part is the pattern, not the artifact.
- What does the bundle actually mutate — Carbon, DateTime, or a PSR-20 clock?
- The overview says it changes the application's notion of datetime, but it does not specify whether it decorates Psr\Clock\ClockInterface, Symfony's clock service, or a custom service. That detail determines coverage: any legacy code that calls new \DateTime() or date() directly will bypass a clock decorator. Before adopting, confirm the injection point and audit your date call sites.
- Which Symfony and PHP versions does symfony-time-machine support?
- The last release was in October 2022, so its Composer constraints likely pin symfony/framework-bundle to ^5 or ^6 and PHP to 7.4 or 8.0–8.1. That will probably conflict with Symfony 7 and PHP 8.3+. If you need those versions, plan to fork and loosen constraints, or just rebuild the utility.
- Is it safe to use a time machine bundle in production?
- No, not by default. Shifting time process-wide can bypass signed-URL expiry, password-reset TTLs, JWT exp/nbf checks, TOTP windows, and rate-limit buckets, so it must be hard-gated to local and test environments and an explicit config flag. Never enable it from request input alone. Treat any HTTP or console surface as dangerous unless it is default-off.
- How do I freeze time in Laravel tests without this package?
- Use Carbon's test helpers: Carbon::setTestNow($dateTime) freezes now for the process, and Carbon::setTestNow() clears it. Call it in setUp or a Pest beforeEach and reset it in tearDown/afterEach to avoid leaking state between tests. For integration tests, a service provider bound to local/testing plus a test-only middleware can set the clock from a header or session key.
- Does Symfony Time Machine affect queue workers, the scheduler, and long-running processes?
- Time travel is global mutable state for the PHP process. Under long-running workers such as Octane, RoadRunner, Swoole, or Symfony Runtime, a shift can leak across requests unless it is reset. Queue workers and scheduler processes only see the shift if they run the same clock binding, so propagation is not automatic. Reset state explicitly in every request and job boundary.
- Is icanhazstring/symfony-time-machine actively maintained?
- Signals are weak: last release 2022-10-14, roughly 7 stars, zero dependents, and a single maintainer. The license is MIT, so forking or reimplementing is legally unencumbered. Expect to own any fork you adopt, including Composer constraint updates for newer Symfony and PHP releases.
- What is the best Laravel alternative to Symfony Time Machine?
- Build a small internal utility: a TimeMachineServiceProvider registered only for local and testing, a Clock contract binding or a Carbon::setTestNow call, and one middleware that reads a test-only header or session key. That is roughly 100–200 lines and about a day of work, and you control the dependency. It avoids the abandoned-bundle risk and the Symfony-to-Laravel mismatch.