Description
This PHP >=5.4 library is a collection of traits and interfaces
that add behaviors to Doctrine2 entities and repositories.
It currently handles:
blameable
filterable
geocodable
joinable
loggable
sluggable
softDeletable
sortable
timestampable
translatable
tree
Doctrine2 Behaviors alternatives and similar libraries
Based on the "Database" category.
Alternatively, view Doctrine2 Behaviors alternatives based on common mentions on social networks and blogs.
-
Medoo
The lightweight PHP database framework to accelerate the development. -
Doctrine Extensions
Doctrine2 behavioral extensions, Translatable, Sluggable, Tree-NestedSet, Timestampable, Loggable, Sortable -
ProxyManager
🎩✨🌈 OOP Proxy wrappers/utilities - generates and manages proxies of your objects -
Eloquent
[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework) -
Baum
Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM. -
Idiorm
A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5. -
RedBean
ORM layer that creates models, config and database on the fly -
Propel
Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP -
Spot2
Spot v2.x DataMapper built on top of Doctrine's Database Abstraction Layer -
Aura.SqlQuery
Independent query builders for MySQL, PostgreSQL, SQLite, and Microsoft SQL Server. -
Atlas.Orm
A data mapper implementation for your persistence model in PHP. -
ATK Data
Data Access PHP Framework for SQL & high-latency databases -
Cake ORM
[READ-ONLY] A flexible, lightweight and powerful Object-Relational Mapper for PHP, implemented using the DataMapper pattern. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp -
Elasticsearch Eloquent
⚡️ Models like Eloquent for Elasticsearch. -
Simple MySQLi Class
:gem: Simple MySQLi Abstraction Layer + Doctrine/DBAL support -
LDBA
High-performance, low-memory-footprint, single-file embedded database for key/value storage -
PHP library access Firebase RESTful API
A working Firebase http client -
Symfony-RDM
Helps with the use of domain driven design & rich domain model in symfony / doctrine applications. -
LazyRecord
The fast ORM for PHP. (This is a history repo, please visit maghead/maghead)
Updating dependencies is time-consuming.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Doctrine2 Behaviors or a related project?
README
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 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
Create rector.php
config:
vendor/bin/rector init
Add Doctrine Behaviors upgrade set to rector.php
:
use Rector\Core\Configuration\Option;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Doctrine\Set\DoctrineSetList;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(DoctrineSetList::DOCTRINE_BEHAVIORS_20);
};
Run Rector:
vendor/bin/rector process src