herrera-io/doctrine-dateinterval
Adds DateInterval support to Doctrine DBAL and ORM. Provides a custom DBAL type (dateinterval) plus a DATE_INTERVAL DQL function so you can map and query PHP DateInterval values in entities and database fields.
DateInterval storage and querying in Doctrine, which is valuable for applications requiring precise time-based calculations (e.g., scheduling, recurring events, or financial instruments with duration fields).doctrine/dbal:^3.x). Direct integration with Laravel’s Eloquent is untested.DateTime/Carbon support and custom accessors/mutators may obviate the need for this package unless complex DQL operations are required.DateInterval as a custom type (e.g., dateinterval column). Migration tools like Laravel Migrations would need custom logic to handle this.DATE_INTERVAL() DQL function for comparisons, which could simplify queries like WHERE interval < DATE_INTERVAL('P1Y'). However, Laravel’s Query Builder lacks direct support for this function.doctrine/dbal:~2.2 may conflict with Laravel’s ^3.x DBAL, requiring forks or compatibility layers.Why Not Use Carbon/Accessors?
DateInterval logic be implemented via Laravel accessors/mutators (e.g., storing P1Y as a string and parsing on retrieval)?WHERE interval < DATE_INTERVAL('P1Y')) that this package uniquely enables?Maintenance Burden
Database Portability
dateinterval column type be handled across databases (MySQL, PostgreSQL, SQLite)? Some may lack native support.Testing Strategy
Laravel Compatibility:
DateIntervalType could be registered globally via a service provider.Carbon + accessors for most use cases unless DQL is mandatory.Database Support:
DateInterval to string/JSON).Assessment Phase:
DateInterval is strictly necessary or if Carbon/accessors suffice.Proof of Concept:
AppServiceProvider:
Type::addType('dateinterval', DateIntervalType::class);
dateinterval columns (may require custom migration logic).Fallback Plan:
P1Y) in the database.DateInterval objects in PHP.Doctrine Version Conflict:
doctrine/dbal:~2.2, but Laravel uses ^3.x. Options:
^3.x.Eloquent vs. ORM:
DateInterval.DATE_INTERVAL() syntax.Carbon/accessors).dateinterval columns and test database portability.herrera-io/doctrine-dateinterval to 1.* and monitor for forks.DATE_INTERVAL('P1Y') in queries instead of Carbon-based logic.DateInterval could bloat schema if overused.DATE_INTERVAL() may impact query planning in some databases.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Doctrine version incompatibility | Integration breaks on Laravel/Doctrine updates | Fork the package or use accessors. |
Database lacks dateinterval type |
Queries fail or data corrupts | Store as string/JSON with accessors. |
| Custom type hydration errors | Silent data corruption | Add validation in setters/getters. |
| Abandoned package security risks | Unpatched vulnerabilities | Audit dependencies; consider alternatives. |
DateInterval syntax (e.g., P1Y vs. PT1H).How can I help you explore Laravel packages today?