grazulex/laravel-arc
Composer 安装命令:
composer require grazulex/laravel-arc
包简介
A Laravel package for elegant and modern Data Transfer Objects (DTOs) management with automatic validation and direct property access
README 文档
README
Generate modern, type-safe Data Transfer Objects (DTOs) in Laravel from clean YAML definitions — with automatic validation, nested support, and fluent collection handling.
Overview
Laravel Arc is a powerful Laravel package that simplifies Data Transfer Object (DTO) management through YAML-driven generation. Define your DTOs in simple YAML files and let Laravel Arc generate type-safe, validated PHP classes with automatic property access and comprehensive collection support.
Think of it as Laravel API Resources, but with stronger typing, automatic validation, and generated from YAML definitions.
🎯 Key Features
- 🏗️ YAML-Driven Generation - Define DTOs in clean, readable YAML
- 🔒 Type Safety - Full PHP 8.3+ type enforcement with readonly properties
- ✅ Automatic Validation - Generate Laravel validation rules from field definitions
- � ModelSchema Integration - 65+ advanced field types (geometric, JSON, enhanced validation)
- �🔄 Field Transformers - Built-in data transformation (trim, slugify, normalize, etc.)
- 📊 Export Formats - Convert to JSON, XML, CSV, YAML, and more
- 🎯 Behavioral Traits - Timestamps, UUIDs, soft deletes, and tagging
- 🚀 Modern PHP - Leverages PHP 8.3+ features and best practices
🔧 Advanced Field Types (ModelSchema Integration)
Laravel Arc integrates with grazulex/laravel-modelschema to provide 65+ advanced field types:
# Traditional Arc types fields: name: type: string age: type: integer # Advanced ModelSchema types fields: coordinates: type: point # Geographic point boundary: type: polygon # Geographic polygon metadata: type: json # JSON with validation tags: type: set # Set collection email: type: email # Enhanced email validation settings: type: jsonb # PostgreSQL JSONB
Supported Advanced Types:
- 🌍 Geometric:
point,polygon,geometry,linestring - 📋 JSON:
json,jsonb,set,array - 📧 Enhanced String:
email,uuid,url,slug,phone - 🔢 Numeric Variations:
bigint,tinyint,decimal,money - 📅 Date/Time:
datetime,timestamp,date,time
📚 Complete Documentation
➡️ Visit the Wiki for complete documentation, examples, and guides
The wiki contains:
- Installation & Setup
- Your First DTO
- Field Types
- Field Transformers
- Artisan Commands
- Complete Examples
📦 Quick Installation
composer require grazulex/laravel-arc
php artisan vendor:publish --provider="Grazulex\LaravelArc\LaravelArcServiceProvider"
🚀 Quick Start
- Create a DTO definition:
php artisan dto:definition-init UserDTO --model=App\\Models\\User --table=users
- Generate the DTO class:
php artisan dto:generate user.yaml
- Use your DTO:
$userData = ['name' => 'John Doe', 'email' => 'john@example.com']; $userDto = UserDTO::fromArray($userData); echo $userDto->name; // 'John Doe' echo $userDto->toJson(); // JSON representation
⚠️ Important Notes
YAML Validation Rules with Commas
When using validation rules that contain commas (like exists:table,column), wrap them in quotes:
# ❌ Wrong - gets split into separate rules rules: [required, exists:users,id] # ✅ Correct - stays as one rule rules: [required, "exists:users,id"]
This applies to rules like: "exists:table,column", "unique:table,column", "in:value1,value2,value3", etc.
📖 Learn More
- 📚 Complete Documentation - Full guides and API reference
- 🚀 Installation & Setup - Installation and first steps
- 💡 Complete Examples - Real-world usage examples
- 🔧 Behavioral Traits - Advanced features and traits
🔧 Requirements
- PHP: ^8.3
- Laravel: ^12.19
- Carbon: ^3.10
🧪 Testing
composer test
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
🔒 Security
Please review our Security Policy for reporting vulnerabilities.
📄 License
Laravel Arc is open-sourced software licensed under the MIT license.
Made with ❤️ by Jean-Marc Strauven
grazulex/laravel-arc 适用场景与选型建议
grazulex/laravel-arc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26 次下载、GitHub Stars 达 9, 最近一次更新时间为 2025 年 06 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「validation」 「attributes」 「laravel」 「dto」 「pest」 「data-transfer-object」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 grazulex/laravel-arc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 grazulex/laravel-arc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 grazulex/laravel-arc 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A library that allows you to easily use the PHP-VCR library in your PHPUnit tests.
This Package provides some usefully console features like the attribute syntax for arguments and options, validation, auto ask and casting.
Adds request-parameter validation to the SLIM 3.x PHP framework
The last validation library you will ever need!
A jQuery augmented PHP library for creating and validating HTML forms
A PHPDoc docblock interpreter that is simple, easy to use, and provides Attribute alternatives.
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-13
