Looking to hire Laravel developers? Try LaraJobs

laravel-doctrine-query maintained by ncphillips

Description
Ergonomic querying traits for Doctrine Entities in Laravel
Last update
2026/07/27 16:09 (dev-annotate-customer-query-builds)
License
Downloads
8

Comments
comments powered by Disqus

Laravel Doctrine Query

Ergonomic querying traits for Doctrine entities in Laravel.

This package gives Doctrine entities an Eloquent-flavoured static query API so you can write User::find(1) instead of reaching for the EntityManager and a repository at every call site.

Installation

composer require ncphillips/laravel-doctrine-query

The service provider is registered automatically via Laravel package discovery.

Usage

Add the Queryable trait to a Doctrine entity:

use Doctrine\ORM\Mapping as ORM;
use Ncphillips\LaravelDoctrineQuery\Queryable;

#[ORM\Entity]
class User
{
    use Queryable;

    // ...
}

You can then query it statically:

User::all();                              // array<User>
User::find($id);                          // ?User
User::findBy(['admin' => true]);          // array<User>
User::findOneBy(['name' => 'Ada']);       // ?User
User::count(['admin' => true]);           // int

User::query()                             // Doctrine\ORM\QueryBuilder, aliased "user"
    ->where('user.admin = :admin')
    ->setParameter('admin', true)
    ->getQuery()
    ->getResult();

The EntityManager is resolved from the Laravel container on demand, so entities stay free of any constructor wiring.

Development

composer install
composer test     # Pest + Orchestra Testbench, integration tests against SQLite
composer lint     # Laravel Pint

Release

This project uses Conventional Commits and git-cliff to manage releases.

# Bump version, tag, and generate changelog
git cliff --bump --tag   # bumps version based on commits since last tag

# Or specify the version explicitly
git cliff --bump --tag --unreleased --prepend CHANGELOG.md

# Generate changelog from scratch (first release)
git cliff --prepend CHANGELOG.md

The workflow:

  1. Merge feature/fix branches with conventional commit messages
  2. Run git cliff --bump to determine the next version from commit history
  3. Review and commit the updated CHANGELOG.md and version bump
  4. Tag the release (git-cliff creates the tag with --tag)
  5. Push tags: git push --tags

License

MIT