oxylabs / doctrine-behaviors
Doctrine Behavior Traits
Installs: 620
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 240
Type:symfony-bundle
Requires
- php: >=7.3
- doctrine/common: ^3.0
- doctrine/dbal: ^2.9
- doctrine/orm: ^2.8
- doctrine/persistence: ^2.0
- nette/utils: ^3.2
- ramsey/uuid: ^4.0
- symfony/cache: ^4.4|^5.2
- symfony/dependency-injection: ^4.4|^5.2
- symfony/framework-bundle: ^4.4|^5.2
- symfony/http-kernel: ^4.4|^5.2
- symfony/polyfill-php80: ^1.22
- symfony/security-core: ^4.4|^5.2
- symfony/string: ^5.2
- symfony/translation-contracts: ^1.0|^2.3
Requires (Dev)
- ext-pdo_mysql: *
- ext-pdo_pgsql: *
- ext-pdo_sqlite: *
- doctrine/annotations: ^1.12
- doctrine/doctrine-bundle: ^2.2
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^0.12.83
- phpstan/phpstan-doctrine: ^0.12.33
- phpstan/phpstan-phpunit: ^0.12.18
- phpunit/phpunit: ^9.5
- psr/log: ^1.1
- rector/rector-prefixed: ^0.10.4
- symplify/amnesia: ^9.2
- symplify/config-transformer: ^9.2
- symplify/easy-coding-standard: ^9.2.18
- symplify/package-builder: ^9.2.18
- symplify/phpstan-extensions: ^9.2.18
- symplify/phpstan-rules: ^9.2.18
- dev-master
- 2.2.1
- 2.2.0
- 2.1.0
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v2.0.0-beta1
- v2.0.0-alpha4
- v2.0.0-alpha3
- v2.0.0-alpha2
- v2.0.0-alpha1
- 1.6.1
- 1.6.0
- 1.5.0
- 1.4.1
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.1
- v1.1.0
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-downgrade-translation-contracts
- dev-versionable
- dev-php-74
This package is not auto-updated.
Last update: 2021-09-20 08:58:31 UTC
README
This PHP library is a collection of traits and interfaces that add behaviors to Doctrine entities and repositories.
It currently handles:
Install
composer require knplabs/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 declare(strict_types=1); namespace App\Repository; use Doctrine\ORM\EntityRepository; use Knp\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/knplabs/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
Upgrade 1.x to 2
There have been many changes between 1 and 2, but don't worry. This package uses Rector, that handles upgrade for you.
composer require rector/rector --dev vendor/bin/rector process src --config vendor/rector/rector/config/set/doctrine-behaviors-20.yaml