zitec/doctrine-behaviors
最新稳定版本:1.0.0
Composer 安装命令:
composer require zitec/doctrine-behaviors
包简介
Doctrine Behavior Traits
README 文档
README
This repository is a fork of knplabs/doctrine-behaviors. The aim of this fork is to provide support for PHP 8.4 and later.
This PHP library is a collection of traits and interfaces that add behaviors to Doctrine entities and repositories.
It currently handles:
Install
composer require zitec/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 Zitec\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/zitec/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
zitec/doctrine-behaviors 适用场景与选型建议
zitec/doctrine-behaviors 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.26k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「tree」 「behaviors」 「translatable」 「timestampable」 「doctrine」 「Blameable」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zitec/doctrine-behaviors 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zitec/doctrine-behaviors 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zitec/doctrine-behaviors 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
jsTree widget for yii2
A Laravel Eloquent model trait for translatable resource
An Astrotomic Translatable extension for Laravel Nova.
Doctrine2 behavior traits - slowhop fork
A Laravel Nova package for translatable fields
A library to extend Object capabilities.
统计信息
- 总下载量: 1.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 38
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04