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 IDTimestampTrait–createdAt,updatedAt(with lifecycle callbacks)SoftDeleteTrait–deletedAt, withdelete()andrestore()methods
Eelan\DoctrineTraits\Contact
PhoneTrait–phoneEmailTrait–email
Eelan\DoctrineTraits\Personal
NameTrait–firstName,lastNameGenderTrait–gender(based on enumGender:MALE,FEMALE,OTHER,UNKNOWN)BirthTrait–birthDate,birthPlace
Eelan\DoctrineTraits\Location
AddressTrait–streetName,streetNumber,postalCode,cityExtendedAddressTrait– extendsAddressTraitand addsregion,countryGpsCoordinateTrait–latitude,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
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-01