brandonlinu/doctrine-utc-bundle
doctrine/dbal for raw queries) ordatetime/timestamp columns may need migrations to enforce UTC storage (e.g., DEFAULT CURRENT_TIMESTAMP → DEFAULT (CONVERT_TZ(NOW(), @@session.time_zone, '+00:00'))).Carbon::now()) will require widespread refactoring to adopt UTC-first patterns.UTC → User’s Timezone) may introduce latency if not cached (e.g., via Carbon or Redis).config/app.php) may conflict with bundle defaults.Carbon macros suffice?Carbon::parse() vs. DB timestamps)?retrieved, saved).UTC → Carbon conversion).TIMESTAMP with time_zone = '+00:00').spatie/laravel-activitylog or Carbon timezone helpers may reduce coupling.created_at = now()).UPDATE table SET created_at = CONVERT_TZ(created_at, @@session.time_zone, '+00:00')).UTCTimeService) to decouple from Laravel’s ORM.doctrine/dbal).where('created_at', '>', now()->utc())).saving to enforce UTC).intl improves timezone handling.| Step | Task | Dependencies | Risk Mitigation |
|---|---|---|---|
| 1 | Install bundle (Symfony) or DBAL (Laravel) | Doctrine setup | Containerize for isolation |
| 2 | Configure doctrine_utc in config/packages (Symfony) or service provider (Laravel) |
Bundle docs | Test with phpunit |
| 3 | Update DDL to enforce UTC (e.g., TIMESTAMP WITH TIME ZONE) |
DB access | Backup before migrations |
| 4 | Refactor models to use UTC accessors/mutators | Codebase audit | Feature flags for gradual rollout |
| 5 | Implement middleware for Eloquent-Doctrine sync | Hybrid ORM | Log mismatches for debugging |
| 6 | Backfill legacy data | Migration scripts | Validate sample records |
2023-01-01 00:00:00 UTC stored as 2022-12-31 18:00:00 in PST).created_at vs. updated_at mismatches).Carbon::testNow() for timezone-aware testing.Carbon::now() vs. DB timestamps).User::withTimezone('America/New_York')) may scale with traffic.TIMESTAMP WITH TIME ZONE in high-write systems (storage overhead).Redis::remember('user_timezone_'.$userId, ...)).| Scenario | Impact | Mitigation |
|---|---|---|
| Timezone Misconfiguration | Data stored in wrong timezone | Enforce UTC at DB level + CI checks |
| Hybrid ORM Inconsistency | Eloquent/Doctrine timestamp drift | Use a single ORM or strict validation |
| Legacy Data Corruption | Historical records invalidated | Audit migrations with sample queries |
| Bundle Abandonment | No security updates | Fork or replace with Laravel-native solution |
| DST Transitions | Off-by-hour errors | Test with Carbon::setTestNow() |
Carbon::parse($timestamp)->tz('UTC')).created_at = now()).assertEquals('UTC', $entity->createdAt->timezone)).timezone_mismatch_errors (custom Sentry event).utc_timestamp_latency (P99 conversion time).How can I help you explore Laravel packages today?