hasanhawary/dynamic-cli
Composer 安装命令:
composer require hasanhawary/dynamic-cli
包简介
A Laravel package providing a dynamic CLI scaffolder for CRUD generation (skeleton).
README 文档
README
Absolutely! I’ve written a full, highly detailed, professional README for your Dynamic CLI CRUD package, with all advanced features, CLI flow, schema examples, enums, translatable fields, relations, file uploads, and best Laravel package practices.
Here’s the complete README you can directly use:
🧠 Dynamic CLI CRUD Generator for Laravel
Dynamic CLI CRUD is a smart, interactive generator for Laravel that creates production-ready CRUD modules (models, controllers, requests, resources, migrations, enums) with automatic schema detection, relations, enums, translatable fields, and file handling.
✨ Key Features
- 🧠 Smart Schema Detection: Detects field types, required fields, unique constraints, enums, file uploads, and relations automatically.
- 🎯 Enum Handling: Automatically generates Enum classes for fields like
status = enum[pending,approved,rejected]. - 🌍 Translatable Fields: Detects multilingual fields (
ar,en, etc.) and stores them in JSON columns. - 🔗 Relations Awareness: Detects
belongsToforeign keys (e.g.,country_id) and sets up metadata for CRUD. - 🖼️ File Uploads: Supports file fields (
file,image, etc.) with category and allowed file types. - ⚡ Interactive CLI: Step-by-step guidance for CRUD generation.
- 📦 Full CRUD Generation: Creates Model, Controller, Request, Resource, Migration, and Enum classes automatically.
- 💪 Force Overwrite: Re-generate existing files safely using
--force. - 🌐 Optional Frontend Integration: Specify a frontend path to scaffold integration-ready modules.
- 📝 Detailed Schema Analysis: Shows a complete mapping of all fields with metadata in CLI before generation.
📦 Installation
Install via Composer:
composer require hasanhawary/dynamic-cli --dev
✅ Auto-discovers the service provider. No manual registration needed.
⚡ Quick Start
Generate a CRUD module interactively:
php artisan cli:crud Product
Or provide the name directly and force overwrite if needed:
php artisan cli:crud Product --force
🔹 Example CLI Flow
==============================================
🧠 Dynamic CLI CRUD Generator
Build smart CRUDs in seconds
⚡ Powered by Hasan Hawary
==============================================
👋 Welcome!
Enter group name (default: DataEntry) [DataEntry]:
>
Custom table name? (press Enter for default) [products]:
>
Do you have a custom JSON schema? (yes/no) [no]:
> yes
💡 Schema Reference Guide
-------------------------------------------------------------
Symbol-based field modifiers:
* => required field (is_nullable = false)
^ => unique field (is_unique = true)
enum[...] => enumeration field (is_enum = true)
Examples:
'*price' => 'float'
'^email' => 'string'
'state' => 'enum[draft,published,archived]'
'name' => ['ar' => '...', 'en' => '...'] // translatable field
'photo' => 'file'
'country_id' => 1 // foreign key
-------------------------------------------------------------
Opening temporary file... Write your JSON schema and save/close.
🔹 JSON Schema Example
{
"*name": {
"ar": "اسم المنتج",
"en": "Product Name"
},
"description": {
"ar": "وصف المنتج",
"en": "Product Description"
},
"^phone": "string",
"photo": "file",
"status": "enum[pending,approved,rejected]",
"country_id": 1
}
🔹 Final Schema Mapping (CLI Output)
🧠 Analyzing schema...
📋 Final Schema Mapping:
- name → json (🌍 translatable, 🚫 not null)
- description → json (🌍 translatable)
- phone → string (🔑 unique)
- photo → file (🖼️ file(jpg|jpeg|png|pdf|doc|docx))
- status → string (🎯 enum[pending|approved|rejected])
- country_id → foreignId (🔗 relation(Country))
🏗 CRUD File Generation
After confirmation, the generator creates:
| File Type | Path Example |
|---|---|
| Enum | app/Enum/DataEntry/StatusEnum.php |
| Model | app/Models/Product.php |
| Controller | app/Http/Controllers/API/DataEntry/ProductController.php |
| Request | app/Http/Requests/DataEntry/ProductRequest.php |
| Resource | app/Http/Resources/DataEntry/ProductResource.php |
| Migration | database/migrations/2025_10_22_172830_create_products_table.php |
Next steps:
php artisan migrate
🔹 Advanced Features
Enum Handling 🎯
- Automatically generates Enum classes for any field defined as
enum[...]. - Enum classes include a static
resolve($value)method for easy mapping.
$status = StatusEnum::resolve('pending'); // returns 'pending'
Translatable Fields 🌍
- Detects JSON structures with language keys (
ar,en). - Stores translations in JSON column for multilingual support.
"*name": { "ar": "اسم المنتج", "en": "Product Name" }
Relations Detection 🔗
- Detects fields ending with
_idor typed asforeignId. - Prepares metadata for
belongsTorelationships automatically.
"country_id": 1
- Generates relation info for controller, resource, and request.
File Uploads 🖼️
- Supports file fields (
file,image,pdf,docx). - Detects category and allowed file types.
- Integrates with Laravel file handling in requests.
"photo": "file"
CLI Options & Metadata
- Force:
--forceto overwrite existing files. - Group: Organize CRUD modules by logical group (e.g., DataEntry).
- Table Name: Auto-generated from model name but customizable.
- Route: Default
api, can be extended toweb.
🔧 Optional Frontend Integration
The CLI can scaffold integration-ready modules for your frontend:
Would you like to integrate this module with a frontend project? (yes/no)
> yes
Please specify the absolute path to your frontend project:
> /path/to/frontend
🤝 Contribution
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature
- Commit your changes:
git commit -am "Add new feature"
- Push the branch:
git push origin feature/my-feature
- Open a pull request
📦 Version Support
- PHP: 8.1 – 8.3
- Laravel: 10.x
📜 License
MIT © Hasan Hawary
🔗 Links
hasanhawary/dynamic-cli 适用场景与选型建议
hasanhawary/dynamic-cli 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 229 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 10 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「cli」 「crud」 「laravel」 「scaffolding」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hasanhawary/dynamic-cli 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hasanhawary/dynamic-cli 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hasanhawary/dynamic-cli 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Gii Generator for double model generation
A PSR-7 compatible library for making CRUD API endpoints
Admin panel generator for Laravel 8 and based on Vuetify Admin, a separate SPA admin framework running on top of REST APIs.
Collection of tools to use the full power of the Enyalius framework
Slim starter / Slim skeleton package to boost your development with Slim framework
统计信息
- 总下载量: 229
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-16