azwhosting / spark-crud-generator
đ Interactive CRUD generator for CodeIgniter 4 â multilingual, smart CLI prompts, safe overwrites, and full CRUD stack (model, entity, controller, views, migration).
Requires
- php: >=7.4
This package is auto-updated.
Last update: 2025-05-06 20:40:03 UTC
README
Choose your language / Choisissez votre langue :
đŹđ§ English version
đ Table of Contents
- âš Features
- âïž Installation
- đ Usage
- đ Options
- đ Localization
- đ Generated Structure
- đĄïž Safeguards
- đ License
âš Features
- Generates Model, Entity, Controller, Views, Migration
- Interactive prompts for field definitions
- Language support (English & French)
- No file overwrite without confirmation
--force
mode to skip confirmations- Clean structure: templates and CRUD folders
- Auto migration execution prompt
- Routes summary automatically displayed after generation
- Direct clickable link to CRUD interface
- Full entity support with
Entity
as object (no array access) - Supports template themes (e.g., default, bootstrap, etc.)
- Modular architecture with dedicated classes per generator (model, controller, views, etc.)
- All code is rendered from .tpl files for full customization
- Header and footer layout support via layout templates
- Detects missing routes and optionally injects them into Routes.php
âïž Installation
Using Composer (recommended)
composer require azwhosting/spark-crud-generator --dev
Then publish the language files:
php spark crud:publish-lang
âïž Manual Installation
You can install the generator manually if you don't use Composer.
Manual installation steps:
- Place the following files in your project:
app/Commands/MakeCrud.php
app/Language/en/CrudGenerator.php
app/Language/fr/CrudGenerator.php
đ Create the folders if they donât exist.
- Run the generator from the Spark CLI:
php spark make:crud
- Follow the interactive prompts to generate your CRUD.
You can now call it via Spark CLI.
đ Usage
php spark make:crud
Follow the prompts:
- Entity name
- Add fields one by one
- File creation with overwrite protection
Example:
php spark make:crud Product
đ§© Custom Templates
You can define your own generation theme by duplicating the default templates:
- Copy the folder
resources/templates/default/
into a new folderresources/templates/your-theme/
- Customize any
.tpl
file (controller, model, views, etc.) - Run
php spark make:crud
and select your theme when prompted
Templates use placeholders like {{entity}}
, {{fields}}
, {{formFields}}
, etc.
đ Automatic Route Injection
After generation, the system offers to automatically inject routes into app/Config/Routes.php
.
- If routes already exist, they will be skipped.
- If missing, the lines from
route.tpl
will be inserted after confirmation. - A backup of
Routes.php
is automatically created before any modification. - Manual fallback is always shown in case of conflict or refusal.
You can customize the injected routes by editing the route.tpl
file inside your selected template.
đ Options
Option | Description |
---|---|
--force or -f |
Force overwrite without any confirmation |
đ Localization
Language files are located in:
app/Language/en/CrudGenerator.php
app/Language/fr/CrudGenerator.php
You can edit them or create your own translations.
đ Generated Structure
app/
âââ Controllers/
â âââ ProductController.php
âââ Entities/
â âââ Product.php
âââ Models/
â âââ ProductModel.php
âââ Views/
â âââ product/
â â âââ index.php
â â âââ create.php
â â âââ edit.php
â â âââ show.php
â âââ templates/
â âââ header.php
â âââ footer.php
âââ Database/
â âââ Migrations/
â âââ 2025-01-01-CreateProductTable.php
đĄïž Safeguards
- Checks if CRUD already exists
- Warns if a table already exists in DB
- Asks before overwriting any file
- Bypass everything with
--force
đ License
MIT License â Free to use, modify, share.
đ«đ· Version française
đ Sommaire
- ⚠Fonctionnalités
- âïž Installation
- đ Utilisation
- đ Options
- đ Localisation
- đ Structure gĂ©nĂ©rĂ©e
- đĄïž SĂ©curitĂ©s
- đ Licence
⚠Fonctionnalités
- GénÚre ModÚle, Entité, ContrÎleur, Vues, Migration
- Interface interactive pour les champs
- Prise en charge de plusieurs langues (FR / EN)
- Aucun fichier écrasé sans confirmation
- Mode
--force
pour tout passer en force - Structure claire : templates et vues par entité
- Suggestion d'exécution automatique de la migration
- Récapitulatif complet des routes à ajouter
- Lien cliquable direct vers l'interface CRUD générée
- Support complet des entités sous forme d'objets (plus d'accÚs tableau)
- Prise en charge des thĂšmes de templates (ex. :
default
,bootstrap
, etc.) - Architecture modulaire avec une classe dédiée par générateur (modÚle, contrÎleur, vues, etc.)
- Tout le code est généré à partir de fichiers
.tpl
entiĂšrement personnalisables - Gestion des layouts
header
etfooter
via des templates dédiés - Détection des routes manquantes et injection automatique optionnelle dans
Routes.php
âïž Installation
Via Composer (recommandé)
composer require azwhosting/spark-crud-generator --dev
Puis publiez les fichiers de langue :
php spark crud:publish-lang
âïž Installation manuelle
Vous pouvez installer le générateur manuellement si vous n'utilisez pas Composer.
Ătapes pour une installation manuelle :
- Placez les fichiers suivants dans votre projet :
app/Commands/MakeCrud.php
app/Language/en/CrudGenerator.php
app/Language/fr/CrudGenerator.php
đ CrĂ©ez les dossiers s'ils n'existent pas.
- Lancez le générateur depuis le terminal Spark :
php spark make:crud
- Suivez les instructions interactives pour générer le CRUD.
𧩠Templates personnalisés
Vous pouvez définir votre propre thÚme de génération en dupliquant les templates par défaut :
- Copiez le dossier
resources/templates/default/
vers un nouveau dossierresources/templates/votre-theme/
- Personnalisez les fichiers
.tpl
(contrĂŽleur, modĂšle, vues, etc.) - Lancez la commande
php spark make:crud
et sĂ©lectionnez votre thĂšme lorsquâil est proposĂ©
Les templates utilisent des balises comme {{entity}}
, {{fields}}
, {{formFields}}
, etc.
đ Injection automatique des routes
Ă la fin de la gĂ©nĂ©ration, le systĂšme vous propose dâajouter automatiquement les routes dans app/Config/Routes.php
.
- Si les routes existent déjà , elles seront ignorées.
- Si elles sont absentes, les lignes de
route.tpl
seront insérées aprÚs confirmation. - Une sauvegarde du fichier
Routes.php
est automatiquement créée avant toute modification. - Un rappel manuel est toujours affiché en cas de refus ou de conflit.
Vous pouvez personnaliser les routes injectées en modifiant le fichier route.tpl
du thÚme utilisé
đ Utilisation
php spark make:crud
Répondez aux questions :
- Nom de l'entité
- Ajout des champs un Ă un
- Création des fichiers avec protections
Exemple :
php spark make:crud Produit
đ Options
Option | Description |
---|---|
--force ou -f |
Forcer l'écrasement des fichiers sans avertissement |
đ Localisation
Les fichiers de langue sont ici :
app/Language/en/CrudGenerator.php
app/Language/fr/CrudGenerator.php
Vous pouvez les modifier ou en ajouter d'autres.
đ Structure gĂ©nĂ©rĂ©e
app/
âââ Controllers/
â âââ ProduitController.php
âââ Entities/
â âââ Produit.php
âââ Models/
â âââ ProduitModel.php
âââ Views/
â âââ produit/
â â âââ index.php
â â âââ create.php
â â âââ edit.php
â â âââ show.php
â âââ templates/
â âââ header.php
â âââ footer.php
âââ Database/
â âââ Migrations/
â âââ 2025-01-01-CreateProduitTable.php
đĄïž SĂ©curitĂ©s
- VĂ©rifie si le CRUD existe dĂ©jĂ
- Préviens si une table est déjà présente dans la BDD
- Demande avant de remplacer un fichier
--force
pour tout automatiser
đ Licence
Licence MIT â Utilisation libre et modification autorisĂ©e.