pixelfederation / doctrine-resettable-em-bundle
使用可重置装饰器装饰默认实体管理器的 Symfony 扩展包。
8.1.0
2024-01-03 11:45 UTC
Requires
- php: >= 8.1
- doctrine/doctrine-bundle: ^2.10
- doctrine/orm: ^2.15
- symfony/config: ^5.4|^6.3|^7.0
- symfony/dependency-injection: ^5.4|^6.3|^7.0
- symfony/proxy-manager-bridge: ^5.4|^6.3|^7.0
- symfony/yaml: ^5.4|^6.3|^7.0
Requires (Dev)
- doctrine/annotations: ^2.0
- friendsofphp/php-cs-fixer: ^3.13.2
- nikic/php-parser: ^4.2
- php-parallel-lint/php-parallel-lint: ^1.3
- phpcompatibility/php-compatibility: ^9.1
- phpmd/phpmd: ^2.8
- phpro/grumphp: ^2.4
- phpstan/phpstan: ^1.0
- phpstan/phpstan-webmozart-assert: ^1.0
- phpunit/phpunit: ^10.2
- pixelfederation/coding-standards: ^2.1
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.4
- symfony/browser-kit: ^5.4|^6.3
- symfony/flex: ^2.3
- symfony/framework-bundle: ^5.4|^6.3
- symfony/http-kernel: ^5.4|^6.3
- symfony/phpunit-bridge: ^6.3
- symplify/config-transformer: ^12.0
- vimeo/psalm: 6.x-dev
- dev-master
- 9.x-dev
- 8.1.0
- 8.0.0
- 7.0.0
- 6.2.0
- 6.1.0
- 6.0.1
- 6.0.0
- 5.1.0
- 5.0.1
- 5.0.0
- 4.0.0
- 3.0.0
- 2.0.0
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/composer/doctrine/orm-2.19.5
- dev-dependabot/composer/phpunit/phpunit-10.5.20
- dev-dependabot/composer/friendsofphp/php-cs-fixer-3.54.0
- dev-dependabot/composer/nikic/php-parser-5.0.2
- dev-dependabot/composer/symfony/flex-2.4.5
- dev-fix/composer-and-pipeline
- dev-resettable_doctrine_logger
- dev-sensio_extra_fw6
- dev-remove_orm_pack
- dev-14_possible_fix
- dev-failover_alive_keeper_fix2
- dev-failover_alive_keeper_fix
- dev-simple_connections_access
- dev-test_github_code_navi
- dev-more_resiliency
This package is auto-updated.
Last update: 2024-08-30 08:55:44 UTC
README
此扩展包适用于那些在每次请求中不初始化 Symfony,而是保持在内存中,并处理多个连续请求的负载(例如,当使用Swoole 扩展包时)。另一个用例是消息队列消费(例如,Symfony 消息传递),在此场景中,在处理消息后需要清除(并可能重置)实体管理器。
此扩展包的最佳功能是,它将所有配置的实体管理器包装在一个 ResettableEntityManager
实例中,该实例能够在遇到异常时重置实体管理器。在每个请求之后,如果请求处理期间发生异常,则清除或重置实体管理器。
另一个特性是在每个请求开始时,都会ping实体管理器连接,这样连接就不会在一段时间后关闭。
安装
composer require pixelfederation/doctrine-resettable-em-bundle
设置
// config/bundles.php return [ //... \PixelFederation\DoctrineResettableEmBundle\PixelFederationDoctrineResettableEmBundle::class => ['all' => true] //... ];
pixel_federation_doctrine_resettable_em: exclude_from_processing: # these entity managers won't be wrapped by the resettable entity manager: entity_managers: - readonly # these dbal connections won't be assigned to the keep alive handler dbal: - readonly # these redis cluster connections won't be assigned to the keep alive handler redis_cluster: - default # default 0 - if set, the connection ping operation will be executed each X seconds # (instead of at the beginning of each request) ping_interval: 10 # default false - if set to true, the app will check if there is an active transaction # in the processed connection, and it will rollback the transaction check_active_transactions: true # for reader writer connections, each has to be defined as 'reader' or 'writer' to be able for the symfony # app to reconnect after db failover. currently only AWS Aurora is supported. failover_connections: default: writer # redis clusters which need to be failed over should be registered here # it's really important to set default timeouts to a low value, e.g. 2 seconds, so the app won't block for too long redis_cluster_connections: default: 'RedisCluster' # connection name (can be literally anything) => redis cluster service id
从 v5 版本迁移到 v6 版本
将所有对 PixelFederation\DoctrineResettableEmBundle\RequestCycle\InitializerInterface
的使用更改为 PixelFederation\DoctrineResettableEmBundle\RequestCycle\Initializer