nucleos/doctrine-extensions
Composer 安装命令:
composer require nucleos/doctrine-extensions
包简介
Useful doctrine event hooks.
README 文档
README
This library provides adds some useful doctrine hooks.
Installation
Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:
composer require nucleos/doctrine-extensions
Usage
Confirmable entities
If you need entities that needs to be confirmed, just implement the Nucleos\Doctrine\Model\Confirmable
in your entity class.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\ConfirmableListener.
Deleteable entities
If you need entities that should be soft deleted, just implement the Nucleos\Doctrine\Model\Deletable
in your entity class.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\DeletableListener.
Lifecyle aware enties
If you need lifecyle information (creation / update date), just implement the Nucleos\Doctrine\Model\LifecycleAware
in your entity class.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\LifecycleDateListener.
Position aware entities
If you need sortable entities, just implement the Nucleos\Doctrine\Model\PositionAware
in your entity class.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\SortableListener.
Unique active entities
If you need entities that should only have one active state, just implement the Nucleos\Doctrine\Model\UniqueActiveAware
in your entity class.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\UniqueActiveListener.
Table prefix
If you need a prefix for all of you application tables and sequences, you could use the TablePrefixEventListener.
If the table name does already start with the defined prefix, it will be ignored.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\TablePrefixEventListener.
Migration usage
-
Update your
idcolumn fromintegertoguid. -
Create a new migration:
// src/Migrations/Version123.php <?php namespace Application\Migrations; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; use Nucleos\Doctrine\Migration\IdToUuidMigration; class Version123 extends AbstractMigration { private IdToUuidMigration $idToUuidMigration; public function __construct(Connection $connection, LoggerInterface $logger) { parent::__construct($connection, $logger); $this->idToUuidMigration = new IdToUuidMigration($this->connection, $logger); } public function postUp(Schema $schema): void { $this->idToUuidMigration->migrate('my_table_name'); } }
Symfony usage
If you want to use this library inside symfony, you can use a bridge.
Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles in config/bundles.php file of your project:
// config/bundles.php return [ // ... Nucleos\Doctrine\Bridge\Symfony\Bundle\NucleosDoctrineBundle::class => ['all' => true], ];
Configure the Bundle
Create a configuration file called nucleos_doctrine.yaml:
# config/packages/nucleos_doctrine.yaml nucleos_doctrine: table: prefix: 'acme_'
License
This library is under the MIT license.
nucleos/doctrine-extensions 适用场景与选型建议
nucleos/doctrine-extensions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43.44k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「sortable」 「doctrine」 「hooks」 「deletable」 「lifecycle」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nucleos/doctrine-extensions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nucleos/doctrine-extensions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nucleos/doctrine-extensions 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easily provide front-end sorting controls for SilverStripe lists
The bundle for easy using json-rpc api on your project
Sortable models for Laravel Eloquent ORM.
Make pimcore migration simple
Bundle Symfony DaplosBundle
Data structure collections, helpers and utilities for yii2 ActiveRecord models(trees, sorts and etc.)
统计信息
- 总下载量: 43.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 36
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-27