chimera / di-symfony
一套连接所有组件的编译器遍历
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- chimera/bus-implementation: ^0.4
- chimera/routing-implementation: ^0.4
- lcobucci/di-builder: ^7.0
Requires (Dev)
- chimera/bus-tactician: ^0.4
- chimera/mapping: ^0.4
- chimera/routing-mezzio: ^0.4
- chimera/serialization-jms: ^0.4
- infection/infection: ^0.21
- lcobucci/coding-standard: ^6.0
- lcobucci/error-handling-middleware: ^1.2
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^0.12
- phpstan/phpstan-deprecation-rules: ^0.12
- phpstan/phpstan-phpunit: ^0.12
- phpstan/phpstan-strict-rules: ^0.12
- phpunit/phpunit: ^9.5
Suggests
- chimera/bus-tactician: To use league/tactician as service bus
- chimera/mapping: To use annotations for mapping services
- chimera/routing-mezzio: To use mezzio/mezzio as routing application
- chimera/serialization-jms: To use jms/serializer to create messages and format content
- lcobucci/error-handling-middleware: To use lcobucci/error-handling-middleware as the error handler for your application
- 1.0.x-dev
- 0.4.x-dev
- 0.4.0
- 0.3.x-dev
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.0
- 0.1.0
- dev-renovate/phpstan-packages
- dev-renovate/test-packages
- dev-renovate/all-minor-patch
- dev-renovate/codecov-codecov-action-4.x
- dev-renovate/actions-cache-4.x
- dev-renovate/major-test-packages
- dev-dependabot/composer/laminas/laminas-diactoros-2.25.2
- dev-renovate/lock-file-maintenance
This package is auto-updated.
Last update: 2024-09-20 17:20:12 UTC
README
术语“奇美拉”(/kɪˈmɪərə/ 或 /kaɪˈmɪərə/)用来描述任何由各种动物的部件组成的神话或虚构动物,或者描述由非常不同的部件组成,或被认为是非常有想象力、不切实际或迷人的事物。
PHP社区中有许多令人惊叹的库,随着PSRs的创建和采用,我们不必一定依赖全栈框架来创建复杂且设计良好的软件。选择要使用的组件并将它们连接起来有时可能有点具有挑战性。
这套包的目标是使这变得更容易(不牺牲质量),让你能够专注于软件的行为。
此包根据你在应用程序中要求的包提供依赖注入容器的配置。通过依赖 symfony/dependency-injection
,我们在编译时(而不是运行时)将组件连接的复杂性放在一边。
在这个过程中有很多隐藏的复杂性,这肯定会影响编译器遍历的组织,但这样做的原因是确保在处理请求时只执行与你的软件相关的事项。
安装
该包可在 Packagist 上获取,您可以使用 Composer 安装它。
composer require chimera/di-symfony
PHP 配置
为了确保我们处理的是正确数据,我们使用 assert()
,这是PHP中一个非常有趣的功能,但不太常用。关于 assert()
的好处是我们可以在生产模式下禁用它,这样我们就没有无用的语句。
因此,对于生产模式,我们建议您在您的 php.ini
中将 zend.assertions
设置为 -1
。对于开发,您应该将 zend.assertions
保持为 1
并将 assert.exception
设置为 1
,这样当出现问题时,PHP会抛出一个 AssertionError
。
有关更多信息,请参阅文档:https://secure.php.net/manual/en/function.assert.php
使用
Symfony DI 组件非常出色,它拥有我们编译容器所需的一切,只需从一组生成的文件中加载它即可。但是,何时更新这些文件的控制权现在在于 Kernel/MicroKernel。然而,我们不一定需要一个 Kernel 来控制这一点,我们可以使用 lcobucci/di-builder
并简单地获取一个 Symfony DI 容器。这正是此包在底层用于创建服务的方法。
许可
MIT,请参阅 LICENSE。