midnightluke/doctrine-relations
Adds Laravel-style relationships to Doctrine entities, letting you define hasOne, hasMany, belongsTo, and belongsToMany associations with simple attributes and query them through an intuitive, Eloquent-like API.
This is an unvetted micro-package (0 stars, 0 dependents, no ecosystem signals), so treat adoption as a code-review exercise before an install exercise.
composer.json on the repo and check the constraints on php, illuminate/*, and doctrine/orm. Given the repo name and the Laravel context, the package almost certainly targets Doctrine ORM inside a Laravel app (via laravel-doctrine/orm or a hand-rolled EntityManager binding). If the constraints top out below your Laravel or Doctrine major version, stop there.composer require midnightluke/doctrine-relations only after confirming it resolves on Packagist; otherwise add it as a VCS repository and pin a commit hash ("midnightluke/doctrine-relations": "dev-main#<sha>"). Never float dev-main in a production app with no maintainer activity.src/ for the service provider and any traits/base classes, then the test suite (tests/) — it is the only reliable spec you have. The README is likely thin; the tests will tell you what the package actually does with associations.OneToMany association and use the package to manage that collection — add/remove children, cascade persist, and read the inverse side — rather than rewriting your whole domain model. Compare the before/after against plain Doctrine cascade: ["persist"] plus your own addChild()/removeChild() methods; if the package is not clearly better, do not adopt it.addX()/removeX() that keep both sides of a bidirectional association in sync. Wrap these behind domain methods ($order->addLine($line)) so controllers never touch raw collections.$em->flush() inside a transaction ($em->wrapInTransaction(...) or DB::transaction around flush). Do not let a relations helper flush implicitly.EntityManager (or a repository from $em->getRepository()) into a small service class; keep Eloquent and Doctrine code paths separate rather than mixing DB::table() with entity hydration.doctrine/orm schema tool (SchemaTool::createSchema) in a base test case, and reset the EntityManager between tests. Assert on both the owning and inverse sides after flush() + $em->clear() to prove the relation actually persisted.laravel-doctrine/orm, register this package's provider after it and verify the EntityManager it resolves is the same instance (identity map mismatches are a classic failure here).Doctrine\Common\Persistence-era APIs will break. Check the ORM constraint in composer.json and run a full association test suite against your target ORM version before trusting it.EntityManager accumulates stale entities. Clear it per job/request ($em->clear()), and never cache entities across requests.EntityManager errors surface late. Prefer explicit JOIN/fetch-join DQL or $em->initialize() in the query layer, and map to DTOs before returning.getCollection() call in a loop. Log queries in dev, or assert query counts in a test, for any list endpoint that renders relations.cascade: ["remove"] plus a real FK without ON DELETE CASCADE produces ordering bugs. Keep the database FK as the safety net and let the ORM cascade be the intent.app/ so upgrades remain possible. Document every assumption about the package's API in a test — those tests are your upgrade contract.Doctrine\DBAL\Logging (or doctrine/dbal middleware in ORM 3) plus $em->getUnitOfWork()->getScheduledEntityInsertions() will tell you quickly whether the helper queued the relation or silently dropped it.How can I help you explore Laravel packages today?