dasprid/container-interop-doctrine
最新稳定版本:1.1.0
Composer 安装命令:
composer require dasprid/container-interop-doctrine
包简介
Doctrine factories for PSR-11
README 文档
README
THIS REPOSITORY IS DEPRECATED - PLEASE VISIT https://github.com/Roave/psr-container-doctrine
Doctrine factories for PSR-11 (previously known as container-interop).
This package provides a set of factories to be used with containers using the PSR-11 standard for an easy Doctrine integration in a project.
Installation
The easiest way to install this package is through composer:
$ composer require dasprid/container-interop-doctrine
Configuration
In the general case where you are only using a single connection, it's enough to define the entity manager factory:
return [ 'dependencies' => [ 'factories' => [ 'doctrine.entity_manager.orm_default' => \ContainerInteropDoctrine\EntityManagerFactory::class, ], ], ];
If you want to add a second connection, or use another name than "orm_default", you can do so by using the static variants of the factories:
return [ 'dependencies' => [ 'factories' => [ 'doctrine.entity_manager.orm_other' => [\ContainerInteropDoctrine\EntityManagerFactory::class, 'orm_other'], ], ], ];
Each factory supplied by this package will by default look for a registered factory in the container. If it cannot find one, it will automatically pull its dependencies from on-the-fly created factories. This saves you the hassle of registering factories in your container which you may not need at all. Of course, you can always register those factories when required. The following additional factories are available:
\ContainerInteropDoctrine\CacheFactory(doctrine.cache.*)\ContainerInteropDoctrine\ConnectionFactory(doctrine.connection.*)\ContainerInteropDoctrine\ConfigurationFactory(doctrine.configuration.*)\ContainerInteropDoctrine\DriverFactory(doctrine.driver.*)\ContainerInteropDoctrine\EventManagerFactory(doctrine.event_manager.*)
Each of those factories supports the same static behavior as the entity manager factory. For container specific configurations, there are a few examples provided in the example directory:
Example configuration
A complete example configuration can be found in example/full-config.php. Please note that the values in there are the defaults, and don't have to be supplied when you are not changing them. Keep your own configuration as minimal as possible. A minimal configuration can be found in example/minimal-config.php
Using the Doctrine CLI
In order to be able to use the CLI tool of Doctrine, you need to set-up a cli-config.php file in your project
directory. That file is generally quite short, and should look something like this for you:
<?php $container = require 'config/container.php'; return new \Symfony\Component\Console\Helper\HelperSet([ 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper( $container->get('doctrine.entity_manager.orm_default') ), ]);
After that, you can simply invoke php vendor/bin/doctrine. It gets a little trickier when you have multiple entity
managers. Doctrine itself has no way to handle that itself, so a possible way would be to have two separate directories
with two unique cli-config.php files. You then invoke the doctrine CLI from each respective directory. Since the
CLI is looking for the config file in the current working directory, it will then always use the one from the directory
you are currently in.
dasprid/container-interop-doctrine 适用场景与选型建议
dasprid/container-interop-doctrine 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 485.73k 次下载、GitHub Stars 达 113, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dasprid/container-interop-doctrine 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dasprid/container-interop-doctrine 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 485.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 116
- 点击次数: 29
- 依赖项目数: 12
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2026-01-04