cleaniquecoders/traitify
Composer 安装命令:
composer require cleaniquecoders/traitify
包简介
Traitify is a Laravel package designed to streamline and enhance your development process by providing a collection of reusable traits and contracts.
README 文档
README
A Laravel package that streamlines development with reusable traits, contracts, and a powerful value generator system. Reduce boilerplate, standardize behavior, and enhance your models with automatic UUID, token, and slug generation.
✨ Features
- 🔧 11 Reusable Traits - UUID, Token, Slug, Meta, User, API, Search, and more
- 🎨 Customizable Generators - Flexible token, UUID, and slug generation
- ⚙️ Three-Tier Configuration - Model → Config → Default resolution
- 🔌 Extensible Architecture - Create custom generators easily
- 📦 Zero Configuration - Works out of the box with sensible defaults
- ✅ 100% Tested - Comprehensive test coverage with Pest PHP
📦 Installation
composer require cleaniquecoders/traitify
🚀 Quick Start
use CleaniqueCoders\Traitify\Concerns\InteractsWithUuid; use Illuminate\Database\Eloquent\Model; class Post extends Model { use InteractsWithUuid; // UUID automatically generated on creation }
$post = Post::create(['title' => 'Hello World']); echo $post->uuid; // 9d9e8da7-78c3-4c9d-9f5e-5c8e4a2b1d3c
📚 Documentation
- Documentation Home - Complete documentation index
- Getting Started - Installation and setup
- Architecture - System design and patterns
- Traits Reference - All available traits
- Generators - Customizable value generation
- Configuration - Configuration options
- Examples - Real-world usage examples
- Advanced - Extend and customize
🔥 Popular Use Cases
Auto-Generate UUIDs
use InteractsWithUuid; protected $uuid_column = 'id'; // Use UUID as primary key
Secure API Tokens
use InteractsWithToken; protected $tokenGeneratorConfig = [ 'length' => 64, 'prefix' => 'sk_', 'pool' => 'hex', ];
SEO-Friendly Slugs
use InteractsWithSlug; protected $slugGeneratorConfig = [ 'unique' => true, 'max_length' => 100, ];
🧪 Testing
composer test
📖 Available Traits
| Trait | Purpose |
|---|---|
InteractsWithUuid |
Auto-generate UUIDs |
InteractsWithToken |
Generate secure tokens |
InteractsWithSlug |
Create URL-friendly slugs |
InteractsWithMeta |
Manage JSON metadata |
InteractsWithUser |
Auto-assign user relationships |
InteractsWithApi |
API response formatting |
InteractsWithSearchable |
Full-text search |
InteractsWithDetails |
Eager load relationships |
InteractsWithEnum |
Enum helper methods |
InteractsWithResourceRoute |
Resource route generation |
InteractsWithSqlViewMigration |
SQL view migrations |
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING for details.
🔒 Security
If you discover any security issues, please review our security policy.
📝 Changelog
Please see CHANGELOG for recent changes.
👥 Credits
📄 License
The MIT License (MIT). Please see License File for more information.
cleaniquecoders/traitify 适用场景与选型建议
cleaniquecoders/traitify 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.83k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2024 年 10 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「traitify」 「Cleanique Coders」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cleaniquecoders/traitify 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cleaniquecoders/traitify 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cleaniquecoders/traitify 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provide organization related app
Spatie Media Library Manager
Effortlessly manage your Laravel API versions with flexible, header-based versioning control.
Alfabank REST API integration
AppPulse provide a comprehensive, easy-to-use monitoring tool with uptime tracking, SSL certificate checks, and customisable notifications.
Define, sign, dispatch and log outgoing webhooks in Laravel with retries, HMAC signatures, and an optional Livewire + Flux admin UI.
统计信息
- 总下载量: 17.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 26
- 依赖项目数: 16
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-15