oro/doctrine-extensions
Adds extra Doctrine DQL functions and field types for MySQL and PostgreSQL (e.g., DATE/TIME, TIMESTAMPDIFF, CONVERT_TZ, DAY/WEEK/MONTH, MD5). Includes registration examples for common frameworks and guidance for extending platforms/functions.
doctrine/orm and doctrine/dbal. Since Laravel already integrates Doctrine, this package can be seamlessly incorporated without disrupting existing ORM workflows.TIMESTAMPDIFF, GROUP_CONCAT, DATE_FORMAT) that map directly to SQL, enabling complex queries without raw SQL. This aligns with Laravel’s preference for query builder/ORM over raw SQL.MoneyType, PercentType): Useful for financial applications but may require custom entity mapping in Laravel (via Doctrine annotations or YAML/XML mappings).doctrine/doctrine-bundle or standalone) supports custom DQL functions. The package’s Symfony/Laminas configuration examples can be adapted for Laravel’s config/packages/doctrine.yaml.FunctionFactory updates).GROUP_CONCAT) may introduce SQL-level aggregation, which could impact query performance on large datasets. Benchmarking is recommended.MoneyType and PercentType are not natively supported in Laravel’s Eloquent. Custom Doctrine mappings would be required, adding complexity.MoneyType/PercentType needed, or can native Laravel/Eloquent solutions (e.g., decimal columns) suffice?GROUP_CONCAT on production-scale data?doctrine/orm + doctrine/dbal.doctrine/doctrine-bundle (common in Laravel with Symfony components).DB::raw() or custom expressions).// Using QueryBuilder with custom DQL function
$qb = $entityManager->createQueryBuilder();
$qb->select('DATE(u.createdAt) as created_date')
->from(User::class, 'u');
DB::select()).composer.json:
"oro/doctrine-extensions": "^3.0"
^2.0.config/packages/doctrine.yaml (Symfony-style):
doctrine:
orm:
dql:
datetime_functions:
date: Oro\ORM\Query\AST\Functions\SimpleFunction
timestampdiff: Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff
string_functions:
group_concat: Oro\ORM\Query\AST\Functions\String\GroupConcat
$config = new \Doctrine\ORM\Configuration();
$config->addCustomDatetimeFunction('date', 'Oro\ORM\Query\AST\Functions\SimpleFunction');
GROUP_CONCAT syntax differs between MySQL/PostgreSQL).^3.0 of the package. If using Doctrine 2.x, use ^2.0.^3.0. If using PHP <8.1, use ^2.0.MoneyType/PercentType, update entity mappings and test.doctrine.yaml.GROUP_CONCAT differences between databases).doctrine.event_listeners.sql_logger).dd() on generated SQL queries.TIMESTAMPDIFF, GROUP_CONCAT) may introduce SQL-level overhead. Test with production-like datasets.DATE() extractions).GROUP_CONCAT can be resource-intensive on large result sets. Consider:
LIMIT/OFFSET).| Risk | Impact | Mitigation |
|---|---|---|
| Doctrine ORM version mismatch | Broken queries, runtime |
How can I help you explore Laravel packages today?