buzzingpixel / corbomite-di
Corbomite DI
Requires
- php: >=7.2
- ext-json: *
- buzzingpixel/corbomite-config-collector: ^1.1
- php-di/php-di: ^6.0
Requires (Dev)
- phpmd/phpmd: ^2.6
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-08-29 04:14:46 UTC
README
是BuzzingPixel的Corbomite项目的一部分。
配置
配置可以在项目的 composer.json
中的 extra
键提供,或者在某些情况下通过环境变量提供。
diConfigFilePath
您的应用程序或任何composer包都可以通过在 composer.json
的 extra
对象中注册配置文件并在键 diConfigFilePath
下加载来注册配置文件。
{ "name": "vendor/name", "extra": { "diConfigFilePath": "src/diConfig.php" } }
该配置文件的返回值应类似于以下内容
<?php declare(strict_types=1); use some\Dependency; use some\OtherDependency; use my\namespaced\CoolClass; use my\namespaced\AnotherCoolClass; return [ CoolClass::class => function () { return new CoolClass(new Dependency()); }, AnotherCoolClass::class => function () { return new AnotherCoolClass( new Dependency(), new OtherDependency() ); }, ];
corbomiteDiConfig.useAutoWiring
默认情况下为 false
以保持向后兼容性。下一个主要版本将默认启用此功能。可选地使用环境变量设置: putenv('CORBOMITE_DI_USE_AUTO_WIRING=true')
corbomiteDiConfig.useAnnotations
默认情况下为 false
以保持向后兼容性。下一个主要版本将默认启用此功能。可选地使用环境变量设置: putenv('CORBOMITE_DI_USE_ANNOTATIONS=true')
corbomiteDiConfig.ignorePhpDocErrors
默认情况下为 false
。可选地使用环境变量设置: putenv('CORBOMITE_DI_IGNORE_PHPDOC_ERRORS=true')
corbomiteDiConfig.compileTo
设置相对于项目 composer.json
的路径。可选地使用环境变量设置(注意:当使用环境变量时,这必须是完整路径而不是相对路径): putenv('CORBOMITE_DI_COMPILATION_DIR=/path/to/directory')
corbomiteDiConfig.writeProxiesTo
设置相对于项目 composer.json
的路径。可选地使用环境变量设置(注意:当使用环境变量时,这必须是完整路径而不是相对路径): putenv('CORBOMITE_DI_WRITE_PROXIES_TO_FILE=/path/to/directory')
CORBOMITE_DI_ENABLE_COMPILATION
环境变量
在生产环境中,您希望将其设置为 true
并确保 corbomiteDiConfig.compileTo
具有有效路径。
CORBOMITE_DI_ENABLE_WRITING_PROXIES
环境变量
在生产环境中,您希望将其设置为 true
并确保 corbomiteDiConfig.writeProxiesTo
具有有效路径。
Di的类方法
diContainer()
(静态) 或 getDiContainer()
(非静态)
获取PHP-DI的配置实例。您可能永远不需要使用此方法。
build()
(静态) 或 buildContainer()
(非静态)
允许您构建容器,例如在front controller中,可以发送任何您想要直接定义的额外定义。
许可证
版权所有 2019 BuzzingPixel, LLC
根据Apache许可证版本2.0(“许可证”)授权;除非适用法律要求或经书面同意,否则不得使用此文件,除非遵守许可证。您可以在 https://apache.ac.cn/licenses/LICENSE-2.0 获取许可证的副本。
除非适用法律要求或经书面同意,否则根据许可证分发的软件按“原样”分发,不提供任何明示或暗示的保证或条件。有关许可证的具体语言管理权限和限制,请参阅许可证。