Giter Site home page Giter Site logo

doctrinebehaviors's Introduction

Doctrine Behaviors

Build Status Downloads

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

Register bundle in config/bundles.php:

<?php

return [
    // ...
    Knp\DoctrineBehaviors\Bundle\DoctrineBehaviorsBundle::class => ['all' => true],
    // ...
];

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:

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/knplabs/doctrine-behaviors/upgrade/rector/doctrine-behaviors-20.yaml

doctrinebehaviors's People

Contributors

docteurklein avatar tomasvotruba avatar everzet avatar pedrotroller avatar akovalyov avatar greg0ire avatar kuczek avatar bocharsky-bw avatar gquemener avatar maxakawizard avatar l3l0 avatar trsteel88 avatar hermann8u avatar toooni avatar emmanuelvella avatar digitalkaoz avatar bobvandevijver avatar dmishh avatar pmontoya avatar boekkooi avatar derekroth avatar cursedcoder avatar fsoedjede avatar inoryy avatar lemoinem avatar alexpozzi avatar akia avatar adrienrusso avatar tobias-93 avatar martinprihoda avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.