eelan/doctrine-traits 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eelan/doctrine-traits

最新稳定版本:0.0.2

Composer 安装命令:

composer require eelan/doctrine-traits

包简介

A collection of traits for Doctrine entities.

README 文档

README

Reusable PHP traits for Doctrine entities, designed for Symfony projects.

This library provides a collection of common traits to reduce boilerplate code when working with Doctrine ORM.

📦 Installation

Install via Composer:

composer require eelan/doctrine-traits

⚠️ If the package is not yet published on Packagist, you can include the GitHub repository manually in your composer.json.

🧱 Available Traits

Eelan\DoctrineTraits\Common

  • IdTrait – Auto-increment integer ID
  • TimestampTraitcreatedAt, updatedAt (with lifecycle callbacks)
  • SoftDeleteTraitdeletedAt, with delete() and restore() methods

Eelan\DoctrineTraits\Contact

  • PhoneTraitphone
  • EmailTraitemail

Eelan\DoctrineTraits\Personal

  • NameTraitfirstName, lastName
  • GenderTraitgender (based on enum Gender: MALE, FEMALE, OTHER, UNKNOWN)
  • BirthTraitbirthDate, birthPlace

Eelan\DoctrineTraits\Location

  • AddressTraitstreetName, streetNumber, postalCode, city
  • ExtendedAddressTrait – extends AddressTrait and adds region, country
  • GpsCoordinateTraitlatitude, longitude, and grouped coordinate helpers

🛠 Usage

In your Doctrine entity:

use Eelan\DoctrineTraits\Common\IdTrait;
use Eelan\DoctrineTraits\Location\AddressTrait;
use Eelan\DoctrineTraits\Contact\EmailTrait;

class Person
{
    use IdTrait;
    use AddressTrait;
    use EmailTrait;

    // your custom fields...
}

All fields are mapped using PHP 8+ attributes (#[ORM\Column(...)]).

🧪 Example Entity

See examples/Person.php for a complete example using all traits.

📄 License

This project is licensed under the MIT License.
See the LICENSE file for details.

🙌 Contributions

Contributions are welcome!
Feel free to open an issue or submit a pull request with new traits or improvements.

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-01