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

v1.1.0 2025-11-13 16:31 UTC

This package is auto-updated.

Last update: 2025-12-13 16:43:54 UTC


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

Latest Stable Version Total Downloads PHP Version License

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 belongsTo foreign 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 _id or typed as foreignId.
  • Prepares metadata for belongsTo relationships 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: --force to 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 to web.

πŸ”§ 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

  1. Fork the repository
  2. Create a feature branch:
git checkout -b feature/my-feature
  1. Commit your changes:
git commit -am "Add new feature"
  1. Push the branch:
git push origin feature/my-feature
  1. Open a pull request

πŸ“¦ Version Support

  • PHP: 8.1 – 8.3
  • Laravel: 10.x

πŸ“œ License

MIT Β© Hasan Hawary

πŸ”— Links