dualmedia/doctrine-query-creator
doctrine/dbal (Laravel’s default database layer).doctrine/orm (not bundled with Laravel by default) but feasible for projects already using it (e.g., hybrid Laravel/Symfony apps or legacy systems).spatie/laravel-query-builder) or custom request DTOs can serve as input.spatie/laravel-query-builder?WHERE name = ?) or complex (e.g., multi-table joins, subqueries)? The package may struggle with the latter without extensions.spatie/laravel-query-builder may suffice.// Example: Criteria -> QueryBuilder
$criteria = new UserFilterCriteria(request()->all());
$query = (new DoctrineQueryCreator())->create($criteria, $entityManager);
composer require dualmedia/doctrine-query-creator doctrine/dbal
composer require doctrine/orm
config/app.php (if not already present).doctrine/dbal constraints).FilterCriteria, SortCriteria) to enforce consistency. Example:
interface FilterCriteria {
public function getFilters(): array;
}
setFirstResult()/setMaxResults() or adapt to Laravel’s paginate().join() or fetch() calls post-creation if needed.QueryCache.$query->getSQL(); // Log this in development
User::find($id)). Benchmark to justify use.SELECT * without limits). Enforce defaults:
$query->setMaxResults(100); // Prevent accidental large fetches
| Risk | Impact | Mitigation |
|---|---|---|
| Package Abandonment | Broken queries, no updates | Fork the repo or migrate to alternatives. |
| Doctrine Version Conflict | App breaks on Laravel updates | Pin Doctrine versions in composer.json. |
| Poor Query Generation | Slow/inefficient SQL | Review generated SQL; add indexes. |
| Criteria Design Flaws | Ambiguous or incomplete filters | Enforce validation in criteria objects. |
| Laravel-Doctrine Mismatch | Hydration issues (e.g., arrays vs. models) | Normalize output (e.g., ->toArray()). |
How can I help you explore Laravel packages today?