hasanhawary / dynamic-cli
A Laravel package providing a dynamic CLI scaffolder for CRUD generation (skeleton).
Installs: 65
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/hasanhawary/dynamic-cli
Requires
- php: >=8.0
- hasanhawary/lookup-manager: ^v1.0.0
- hasanhawary/media-manager: ^v1.0.1
- illuminate/console: ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
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