Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Doctrine Utils

Doctrine Utils Laravel Package

ecommit/doctrine-utils

Small set of Doctrine ORM QueryBuilder utilities: accurate COUNT helpers, a paginator, and filter helper methods. Install via Composer and use to simplify common query building patterns in your PHP projects.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Doctrine Utils
Can I use this package in a Laravel project that only uses Eloquent?
This package is designed for Doctrine ORM/DBAL, not Eloquent. If your project relies solely on Eloquent, the value is limited unless you’re extending QueryBuilder directly in custom repositories or services. For Eloquent-only projects, Laravel’s built-in pagination and counting methods are sufficient.
How do I install and set up ecommit/doctrine-utils in Laravel?
Install via Composer with `composer require ecommit/doctrine-utils`. No additional Laravel-specific configuration is needed, but ensure your project has Doctrine ORM/DBAL installed (e.g., `doctrine/orm` or `doctrine/dbal`). The package integrates directly with Doctrine’s QueryBuilder, so no Laravel service provider or facade setup is required.
Does this package support Laravel’s latest version?
The package itself doesn’t enforce Laravel version constraints, but it requires Doctrine ORM/DBAL, which Laravel supports via packages like `doctrine/dbal`. Ensure your Doctrine version is compatible with Laravel’s ecosystem (e.g., Laravel 10+ typically works with Doctrine 2.10+). Check the package’s `composer.json` for Doctrine version requirements.
How does the DoctrinePaginatorBuilder compare to Laravel’s native paginator?
DoctrinePaginatorBuilder offers fine-grained control over QueryBuilder operations, including complex joins, subqueries, and custom counting logic, which can optimize performance in scenarios where Laravel’s `paginate()` or `cursor()` methods fall short. It’s ideal for legacy systems or hybrid architectures where Doctrine is already in use, but it lacks Laravel’s built-in integration with collections and views.
Are there any security risks with dynamic filter helpers?
The filter helpers use Doctrine’s QueryBuilder, which inherently protects against SQL injection by parameterizing inputs. However, ensure you’re passing sanitized or trusted identifiers (e.g., `by_identifier()`) to avoid exposing your application to unsafe dynamic queries. Always validate inputs before passing them to the filter methods.
Can I migrate from Laravel’s Paginator to this package incrementally?
Yes, start by replacing critical pagination or counting logic in repositories or services that use raw QueryBuilder. For example, swap Eloquent’s `count()` for `DoctrinePaginatorBuilder::countQueryBuilder()` in performance-critical paths. Wrap the package behind a service layer to isolate changes and test thoroughly before full adoption.
What Laravel versions and Doctrine versions does this package support?
The package doesn’t enforce Laravel version constraints but requires Doctrine ORM/DBAL (typically 2.5+). Laravel 8+ projects should verify Doctrine compatibility (e.g., Laravel 10 works with Doctrine 2.10+). Check the package’s `composer.json` for exact Doctrine version requirements, as it may not explicitly list Laravel versions.
How do I handle testing with this package in Laravel?
Test the package by mocking Doctrine’s `EntityManager` and `QueryBuilder` in PHPUnit. For example, use `createMock(EntityManager::class)` and inject it into your service layer. Verify counting, pagination, and filter logic by asserting SQL queries or results against expected outputs. The package’s MIT license allows forking if you need custom test utilities.
Are there alternatives to this package for Laravel/Doctrine pagination?
For Laravel projects, consider native `paginate()` or `cursor()` methods if using Eloquent. For Doctrine-specific needs, alternatives include `KnpPaginator` (for Doctrine 1.x) or custom QueryBuilder logic. This package stands out for its lightweight, focused utilities (counting, pagination, filters) without heavy dependencies, making it ideal for hybrid Laravel/Doctrine setups.
How do I optimize performance with this package in production?
Benchmark the package against native Laravel/Eloquent methods for critical queries. Use `DoctrinePaginatorBuilder::countQueryBuilder()` to avoid N+1 queries in complex counts. For pagination, ensure `max_per_page` is set appropriately and leverage Doctrine’s caching layer if enabled. Monitor query execution plans to identify bottlenecks.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor