azwhosting/spark-crud-generator
最新稳定版本:v1.1.0
Composer 安装命令:
composer require 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).
README 文档
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
--forcemode 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
Entityas 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
.tplfile (controller, model, views, etc.) - Run
php spark make:crudand 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.tplwill be inserted after confirmation. - A backup of
Routes.phpis 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
--forcepour 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
.tplentièrement personnalisables - Gestion des layouts
headeretfootervia 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:crudet 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.tplseront insérées après confirmation. - Une sauvegarde du fichier
Routes.phpest 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
--forcepour tout automatiser
📝 Licence
Licence MIT — Utilisation libre et modification autorisée.
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-02