vasyaxy/doctrine-behaviors

Doctrine Behavior Traits for symfony 7+

Installs: 19

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 274

Type:symfony-bundle

v1.3 2023-12-10 16:45 UTC

This package is auto-updated.

Last update: 2024-04-11 09:39:17 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() and TranslatableInterface::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