setono/doctrine-orm-trait 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

setono/doctrine-orm-trait

最新稳定版本:v1.2.0

Composer 安装命令:

composer require setono/doctrine-orm-trait

包简介

A very simple library that offers a trait to get the object manager and repository for a given class

README 文档

README

Latest Version Software License Build Status Code Coverage Mutation testing

If you are like and me and usually don't inject entity managers directly, but inject the manager registry instead then this little library will come in handy.

Installation

composer require setono/doctrine-orm-trait

Usage

<?php use Doctrine\Persistence\ManagerRegistry; use Setono\Doctrine\ORMTrait; final class YourClass { /**  * Include this trait to use the getManager() and getRepository() methods below  */ use ORMTrait; public function __construct(ManagerRegistry $managerRegistry) { $this->managerRegistry = $managerRegistry; } public function someMethod(): void { /**  * $entity<T> is an entity managed by Doctrine or a class-string representing an entity managed by Doctrine  */ $entity = ; /** @var \Doctrine\ORM\EntityRepository<T> $repository */ $repository = $this->getRepository($entity); /** @var \Doctrine\ORM\EntityManagerInterface $manager */ $manager = $this->getManager($entity); // or do the following to get the default entity manager /** @var \Doctrine\ORM\EntityManagerInterface $manager */ $manager = $this->getManager(); $manager->persist($entity); $manager->flush(); } }

统计信息

  • 总下载量: 58.39k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 18
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04