convertToUtc() calls in models). This is cleaner than ad-hoc solutions but requires Doctrine DBAL (Laravel uses it under the hood).FrameworkBundle), reducing risk.DateTime casting and accessors.created_at, updated_at timestamps if they’re hardcoded to assume local time.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Doctrine DBAL Overhead | Adds listeners to all INSERT/UPDATE queries, which could impact performance. |
Benchmark with production-like load; consider disabling for non-critical tables. |
| Carbon vs. Native PHP | Laravel uses Carbon; package may assume native DateTime. |
Test with Carbon objects; ensure no breaking conflicts. |
| Migration Impact | Existing data may be in inconsistent timezones. | Provide a data migration tool to backfill timestamps to the unified timezone. |
| Symfony-Specific Code | Package assumes Symfony’s autowiring/config system. | Laravel’s service container can wrap the bundle’s logic in a Laravel-compatible service. |
| Edge Cases | Timezone conversions for NULL values, legacy data, or custom DB types. |
Add input validation and fallback logic for unsupported cases. |
created_at/updated_at timestamps?
INSERT/UPDATE?createFromFormat(), setTimezone(), etc.->setTimezone('UTC') in models.getUtcCreatedAt().User) to verify timezone consistency.| Component | Compatibility Status | Notes |
|---|---|---|
| Laravel Eloquent | ✅ High (uses Doctrine DBAL) | No changes needed; listeners will intercept all queries. |
| Carbon | ✅ High | Package should work with Carbon objects out of the box. |
| Query Builder | ✅ High | Same DBAL integration as Eloquent. |
| Migrations | ✅ High | Timestamps in migrations will now use the unified timezone. |
| Legacy Data | ⚠️ Medium | Existing data may need manual correction (e.g., UPDATE posts SET created_at = ...). |
| Third-Party Pkgs | ⚠️ Low (varies) | Packages using raw PDO or custom DB logic may break. |
composer require assistenzde/database-timezone
config/database_timezone.php (Laravel-style) or adapt Symfony’s YAML:
'database_timezone' => [
'database' => 'UTC',
]
public function boot()
{
$this->app->make('assistenzde\database_timezone\DatabaseTimezoneListener')->register();
}
created_at is stored in UTC.Carbon::parse($model->created_at) respects the timezone.DB::table('posts')->update([
'created_at' => DB::raw('CONVERT_TZ(created_at, "local", "UTC")')
]);
->setTimezone('UTC') in controllers).setTimezone() calls in models/controllers.created_at is in local time").InvalidArgumentException for unsupported timezones.INSERT/UPDATE triggers a timezone conversion. Benchmark with:
AT TIME ZONE) as a fallback.How can I help you explore Laravel packages today?