vasyaxy / doctrine-behaviors
symfony 7+ 的 Doctrine 行为特性
v1.3
2023-12-10 16:45 UTC
Requires
- php: >=8.2
- doctrine/common: ^3.3
- doctrine/dbal: ^3.3
- doctrine/doctrine-bundle: ^2.6
- doctrine/orm: ^2.12
- doctrine/persistence: ^2.5|^3.0
- nette/utils: ^3.2
- ramsey/uuid: ^4.2
- symfony/cache: ^5.4|^6.0|^7.0|^8.0
- symfony/dependency-injection: ^5.4|^6.0|^7.0|^8.0
- symfony/framework-bundle: ^5.4|^6.0|^7.0|^8.0
- symfony/http-kernel: ^5.4|^6.0|^7.0|^8.0
- symfony/security-core: ^5.4|^6.0|^7.0|^8.0
- symfony/string: ^5.4|^6.0|^7.0|^8.0
- symfony/translation-contracts: ^2.4|^3.0|^4.0|^5.0
Requires (Dev)
- ext-pdo_mysql: *
- ext-pdo_pgsql: *
- ext-pdo_sqlite: *
- doctrine/annotations: ^1.13
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.7.10
- phpstan/phpstan-doctrine: ^1.3
- phpstan/phpstan-phpunit: ^1.1
- phpunit/phpunit: ^9.5
- psr/log: ^1.1
- rector/rector: ^0.13.4
- symplify/easy-ci: ^10.2.9
- symplify/easy-coding-standard: ^10.2.9
- symplify/package-builder: ^10.2.9
- symplify/phpstan-extensions: ^10.2.9
- symplify/phpstan-rules: ^10.2.9
This package is auto-updated.
Last update: 2024-09-11 10:28:31 UTC
README
这是从 knplabs/doctrine-behaviors 分支出来的 symfony 7 的分支
这是一个 PHP 库,它包含了一系列特性接口,用于向 Doctrine 实体和仓库添加行为。
目前支持以下功能
安装
composer require vasyaxy/doctrine-behaviors
使用
您只需要定义一个 Doctrine 实体
- 实现了接口
- 添加一个特性
对于一些行为,如树形结构,您可以使用仓库特性
<?php namespace App\Repository; use Doctrine\ORM\EntityRepository; use VasyaXY\DoctrineBehaviors\ORM\Tree\TreeTrait; final class CategoryRepository extends EntityRepository { use TreeTrait; }
好了!
现在您有一个可以工作的 Category
,它具有以下行为。
PHPStan
有一个 PHPStan 扩展可用,提供以下功能
- 为
TranslatableInterface::getTranslations()
和TranslatableInterface::getNewTranslations()
提供正确的返回类型 - 为
TranslatableInterface::translate()
提供正确的返回类型 - 为
TranslationInterface::getTranslatable()
提供正确的返回类型
在您的项目 PHPStan 配置中包含 phpstan-extension.neon
# phpstan.neon includes: - vendor/vasyaxy/doctrine-behaviors/phpstan-extension.neon
贡献步骤
-
每个 pull-request 一个特性
-
新特性需要测试
-
测试和静态分析 必须通过
vendor/bin/phpunit composer fix-cs composer phpstan