vasyaxy / doctrine-behaviors
Doctrine Behavior Traits for symfony 7+
Installs: 468
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 305
Type:symfony-bundle
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: 2025-03-11 11:39:05 UTC
README
This is fork for symfony 7 from knplabs/doctrine-behaviors
This PHP library is a collection of traits and interfaces that add behaviors to Doctrine entities and repositories.
It currently handles:
Install
composer require vasyaxy/doctrine-behaviors
Usage
All you have to do is to define a Doctrine entity:
- implemented interface
- add a trait
For some behaviors like tree, you can use repository traits:
<?php namespace App\Repository; use Doctrine\ORM\EntityRepository; use VasyaXY\DoctrineBehaviors\ORM\Tree\TreeTrait; final class CategoryRepository extends EntityRepository { use TreeTrait; }
VoilĂ !
You now have a working Category
that behaves like.
PHPStan
A PHPStan extension is available and provides the following features:
- Provides correct return type for
TranslatableInterface::getTranslations()
andTranslatableInterface::getNewTranslations()
- Provides correct return type for
TranslatableInterface::translate()
- Provides correct return type for
TranslationInterface::getTranslatable()
Include phpstan-extension.neon
in your project's PHPStan config:
# phpstan.neon includes: - vendor/vasyaxy/doctrine-behaviors/phpstan-extension.neon
3 Steps to Contribute
-
1 feature per pull-request
-
New feature needs tests
-
Tests and static analysis must pass:
vendor/bin/phpunit composer fix-cs composer phpstan