Modular CRUD Generator for Laravel + Vue + Tailwind (shadcn-vue)
ngodingskuyy/laravel-module-generator is a Laravel package for modular crud generator for laravel + vue + tailwind (shadcn-vue).
It currently has 2 GitHub stars and 187 downloads on Packagist (latest version v4.8.3).
Install it with composer require ngodingskuyy/laravel-module-generator.
Discover more Laravel packages by ngodingskuyy
or browse all Laravel packages to compare alternatives.
Last updated
๐ Laravel 12+ Focused Module Generator
Modular CRUD Generator for Laravel + Vue + Tailwind (shadcn-vue) - Optimized for Laravel 12+ with PHP 8.2+
Version 4.6 is a complete refactor focused exclusively on Laravel 12+ with comprehensive testing, improved code generation, modern best practices, and smart routes auto-installation.
composer require ngodingskuyy/laravel-module-generator --dev
Due to older versions on Packagist, you might need to install from source:
# Option 1: Install from GitHub (Recommended)
composer config repositories.ngodingskuyy-laravel-module-generator vcs https://github.com/ilhamridho04/laravel-module-generator
composer require ngodingskuyy/laravel-module-generator:dev-main --dev
# Option 2: Local development
git clone https://github.com/ilhamridho04/laravel-module-generator.git packages/laravel-module-generator
composer config repositories.local path ./packages/laravel-module-generator
composer require ngodingskuyy/laravel-module-generator:@dev --dev
For detailed troubleshooting, see DEVELOPMENT.md
module:setup and module:install commandsroutes/app.php and traditional routescomposer require ngodingskuyy/laravel-module-generator --dev
For local development/testing:
{
"repositories": [
{
"type": "path",
"url": "./path/to/laravel-module-generator"
}
]
}
Then:
composer require ngodingskuyy/laravel-module-generator:@dev
# Interactive menu will appear to choose generation mode
php artisan module:create User
Interactive Menu Options:
๐ฏ Pilih mode pembuatan fitur:
1. Full-stack (API + Views) - Lengkap dengan controller, routes, views
2. API Only - Hanya API controller, routes, dan requests
3. View Only - Hanya Vue views dan web controller
๐ค Pilih mode generation
[1] Full-stack (API + Views)
[2] API Only
[3] View Only
> 1
Generate only API controllers, routes, and requests (no Vue views):
php artisan module:create User --api
What gets generated:
app/Http/Controllers/Api/ folderroutes/Modules/Users/api.php) with auth:sanctum middlewareFile Structure:
app/
โโโ Http/
โ โโโ Controllers/
โ โ โโโ API/
โ โ โโโ UserController.php # API Controller
โ โโโ Requests/
โ โโโ StoreUserRequest.php
โ โโโ UpdateUserRequest.php
โโโ Models/
โโโ User.php
routes/
โโโ Modules/
โโโ Users/
โโโ api.php # API routes
Generate only Vue views and web controllers (no API routes or requests):
php artisan module:create User --view
What gets generated:
auth middlewareroutes/Modules/Users/web.php)Generate both API and Views (complete CRUD):
# These are equivalent
php artisan module:create User
# Select option 1 in interactive menu
What gets generated:
php artisan module:create User --with=factory,policy,observer,enum,test
php artisan module:create User --force
php artisan module:delete User
php artisan module:delete User --with=factory,policy,observer,enum,test
php artisan module:delete User --all
php artisan module:delete User --force
The module:delete command will remove:
--with or --all)โ ๏ธ Warning: This action is irreversible. Make sure to backup your files or use version control.
# Setup and install routes automatically
php artisan module:install
This will:
routes/modules.php (web routes loader)routes/api-modules.php (API routes loader)routes/web.php or routes/app.php (Laravel 11+)routes/api.php# 1. Create loader files only
php artisan module:setup
# 2. Then manually add to routes/web.php:
# require __DIR__ . '/modules.php';
# 3. And to routes/api.php:
# require __DIR__ . '/api-modules.php';
When you generate a feature, the system will automatically detect if routes are not installed and offer to install them:
php artisan module:create Product
# Output:
# โ ๏ธ Untuk mengaktifkan auto-loading web modules, pilih salah satu:
# 1. Otomatis install:
# php artisan module:install
#
# 2. Manual install:
# Di routes/web.php:
# require __DIR__ . '/modules.php';
#
# ๐ค Mau auto-install sekarang? (yes/no) [yes]:
After installation, your routes will be organized like this:
routes/
โโโ web.php # Contains: require __DIR__ . '/modules.php';
โโโ api.php # Contains: require __DIR__ . '/api-modules.php';
โโโ modules.php # Auto-loads all web.php from Modules/
โโโ api-modules.php # Auto-loads all api.php from Modules/
โโโ Modules/
โโโ Products/
โโโ web.php # Web routes with auth middleware
โโโ api.php # API routes with auth:sanctum middleware
Running php artisan module:create User will generate:
๐ Generated Files:
โโโ app/Models/User.php # Eloquent Model with SoftDeletes
โโโ app/Http/Controllers/UserController.php # Resource Controller
โโโ app/Http/Requests/StoreUserRequest.php # Store Validation
โโโ app/Http/Requests/UpdateUserRequest.php # Update Validation
โโโ resources/js/pages/Users/
โ โโโ Index.vue # List View
โ โโโ Create.vue # Create Form
โ โโโ Edit.vue # Edit Form
โ โโโ Show.vue # Detail View
โโโ routes/Modules/Users/web.php # Module Routes
โโโ database/seeders/Permission/UsersPermissionSeeder.php # Permissions
โโโ database/migrations/2025_xx_xx_create_users_table.php # Migration
๐ Optional Components (with --with flag):
โโโ app/Factories/UserFactory.php # Model Factory
โโโ app/Policies/UserPolicy.php # Authorization Policy
โโโ app/Observers/UserObserver.php # Model Observer
โโโ app/Enums/UserStatus.php # Status Enum
โโโ tests/Feature/UserFeatureTest.php # Feature Tests
The Laravel Module Generator provides four main commands for complete feature lifecycle management:
| Command | Description | Purpose |
|---------|-------------|---------|
| module:create | Generate complete CRUD feature | Create new features |
| module:delete | Remove complete CRUD feature | Clean up features |
| setup:modules-loader | Create modular route loader | Setup route automation |
| install:modules-loader | Install route loader into Laravel | Integrate with Laravel routing |
module:create CommandSignature: module:create {name} {--with=*} {--force}
Generates a complete CRUD feature with all necessary files including models, controllers, views, migrations, routes, and permissions.
| Argument | Type | Required | Description |
|----------|------|----------|-------------|
| name | string | Yes | The name of the feature to generate (PascalCase) |
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| --with | array | [] | Optional components to include |
| --force | flag | false | Overwrite existing files without confirmation |
--with)| Component | Description | Generated Files |
|-----------|-------------|-----------------|
| factory | Model factory for testing | database/factories/{Name}Factory.php |
| policy | Authorization policy | app/Policies/{Name}Policy.php |
| observer | Model observer | app/Observers/{Name}Observer.php |
| enum | Status enum class | app/Enums/{Name}StatusEnum.php |
| test | Feature test class | tests/Feature/{Name}Test.php |
# Models
app/Models/{Name}.php
# Controllers
app/Http/Controllers/{Name}Controller.php
# Requests
app/Http/Requests/{Name}/Store{Name}Request.php
app/Http/Requests/{Name}/Update{Name}Request.php
# Vue Components
resources/js/Pages/{Name}/Index.vue
resources/js/Pages/{Name}/Create.vue
resources/js/Pages/{Name}/Edit.vue
resources/js/Pages/{Name}/Show.vue
# Database
database/migrations/{timestamp}_create_{name}_table.php
# Routes
routes/{name}.php
# Seeders
database/seeders/{Name}PermissionSeeder.php
# Basic feature generation
php artisan module:create Product
# With optional components
php artisan module:create Product --with=factory,policy,observer
# With all optional components
php artisan module:create Product --with=factory,policy,observer,enum,test
# Force overwrite existing files
php artisan module:create Product --force
# Multiple optional components (alternative syntax)
php artisan module:create Product --with factory --with policy --with observer
| Code | Meaning |
|------|---------|
| 0 | Success - All files generated successfully |
| 1 | Error - Missing required arguments or validation failed |
| 2 | Error - File already exists and --force not specified |
module:delete CommandSignature: module:delete {name} {--with=*} {--all} {--force}
Safely removes all files associated with a feature, including optional components and empty directories.
| Argument | Type | Required | Description |
|----------|------|----------|-------------|
| name | string | Yes | The name of the feature to delete (PascalCase) |
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| --with | array | [] | Optional components to delete |
| --all | flag | false | Delete all components (core + optional) |
| --force | flag | false | Delete without confirmation prompt |
Core Files (always deleted):
Optional Files (with --with or --all):
Directory Cleanup:
# Delete core feature files
php artisan module:delete Product
# Delete with specific optional components
php artisan module:delete Product --with=factory,policy
# Delete everything (core + all optional)
php artisan module:delete Product --all
# Force delete without confirmation
php artisan module:delete Product --force
# Delete with confirmation showing file list
php artisan module:delete Product --with=factory,policy,observer
When --force is not used, the command shows:
| Code | Meaning |
|------|---------|
| 0 | Success - All specified files deleted |
| 1 | Error - Feature not found or validation failed |
| 2 | Cancelled - User declined confirmation |
setup:modules-loader CommandSignature: setup:modules-loader {--force}
Creates the modular route loader file that automatically discovers and loads route files from the routes/modules/ directory.
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| --force | flag | false | Overwrite existing modules.php file |
routes/modules.php # Main modules loader file
routes/modules/ directory# Create modules loader
php artisan setup:modules-loader
# Force overwrite existing file
php artisan setup:modules-loader --force
The generated routes/modules.php contains:
install:modules-loader CommandSignature: install:modules-loader {--force}
Integrates the modules loader into Laravel's main routing system by adding the include statement to routes/web.php.
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| --force | flag | false | Add include even if already exists |
File Modified: routes/web.php
Added Code:
// Auto-load module routes
if (file_exists(__DIR__ . '/modules.php')) {
require __DIR__ . '/modules.php';
}
# Install modules loader into Laravel routing
php artisan install:modules-loader
# Force reinstall even if already present
php artisan install:modules-loader --force
routes/modules.php existsroutes/web.php for existing installationAfter setting up the modular loader system:
routes/
โโโ web.php # Main Laravel routes (includes modules.php)
โโโ modules.php # Auto-generated modules loader
โโโ modules/ # Your modular routes directory
โโโ products.php # Product feature routes
โโโ users.php # User feature routes
โโโ admin/ # Admin module subdirectory
โ โโโ dashboard.php # Admin dashboard routes
โ โโโ reports.php # Admin reports routes
โโโ api/ # API module subdirectory
โโโ v1.php # API v1 routes
โโโ v2.php # API v2 routes
routes/modules/products.php:
<?php
use App\Http\Controllers\ProductController;
use Illuminate\Support\Facades\Route;
Route::middleware(['auth', 'verified'])->group(function () {
Route::resource('products', ProductController::class);
Route::get('products/{product}/history', [ProductController::class, 'history'])->name('products.history');
});
You can publish and customize the stub templates:
# Publish stub files (if supported)
php artisan vendor:publish --tag=laravel-module-generator-stubs
# Or manually copy from:
vendor/ngodingskuyy/laravel-module-generator/src/stubs/
vendor/ngodingskuyy/laravel-module-generator/src/views/
src/stubs/
โโโ controller.stub # Controller template
โโโ model.stub # Model template
โโโ request.store.stub # Store request template
โโโ request.update.stub # Update request template
โโโ migration.stub # Migration template
โโโ routes.stub # Routes template
โโโ seeder.permission.stub # Permission seeder template
โโโ Enum.stub # Enum template
โโโ Observer.stub # Observer template
โโโ modules-loader.stub # Modules loader template
src/views/
โโโ Index.vue.stub # Index view template
โโโ Create.vue.stub # Create view template
โโโ Edit.vue.stub # Edit view template
โโโ Show.vue.stub # Show view template
Development:
--force flag cautiously to avoid overwriting customizationsvendor/bin/phpunitProduction:
--dev dependency onlyphp artisan route:cacheWhen using --with=test, generates:
// tests/Feature/{Name}Test.php
class ProductTest extends TestCase
{
/** @test */
public function it_can_list_products() { /* ... */ }
/** @test */
public function it_can_create_product() { /* ... */ }
/** @test */
public function it_can_update_product() { /* ... */ }
/** @test */
public function it_can_delete_product() { /* ... */ }
}
# Run all tests
vendor/bin/phpunit
# Run specific feature tests
vendor/bin/phpunit tests/Feature/ProductTest.php
# Run with coverage
vendor/bin/phpunit --coverage-html coverage/
File Already Exists:
# Solution: Use --force flag
php artisan module:create Product --force
Permission Denied:
# Solution: Check directory permissions
chmod 755 app/Http/Controllers/
chmod 755 resources/js/Pages/
Stub File Missing:
# Solution: Reinstall package or check vendor directory
composer reinstall ngodingskuyy/laravel-module-generator
Route Not Loading:
# Solution: Check modules.php exists and is included
php artisan route:list | grep products
# Check if commands are registered
php artisan list | grep "module:create\|module:delete\|setup:modules\|install:modules"
# Verify file generation
php artisan module:create TestFeature --force
ls -la app/Models/TestFeature.php
php artisan module:delete TestFeature --force
Version 4.2 includes a comprehensive test suite with 37 tests and 164 assertions achieving 100% pass rate:
ServiceProviderTest - Package registration and command availabilityMakeFeatureCommandUnitTest - Command structure and signature validationStubFilesTest - All stub files validation and placeholder checkingStubRenderingTest - Stub rendering and replacement logicMakeFeatureCommandTest - File generation and content validationMakeFeatureCommandIntegrationTest - End-to-end command testingAutomated testing pipeline with comprehensive validation:
# .github/workflows/run-tests.yml
Pipeline Features:
module:create functionality with all options# Run all 37 tests
vendor/bin/phpunit
# Run with detailed output
vendor/bin/phpunit --testdox
# Run specific test groups
vendor/bin/phpunit tests/Unit/
vendor/bin/phpunit tests/Feature/
# Generate coverage report
vendor/bin/phpunit --coverage-html coverage-report
The test suite validates:
--force and --with options work correctly./vendor/bin/phpunit --coverage-html coverage-report
# or use the provided script
./coverage.sh
# Install in a test Laravel 12 project
composer create-project laravel/laravel test-app
cd test-app
composer config repositories.local path ../
composer require ngodingskuyy/laravel-module-generator:@dev
# Test the command
php artisan module:create Product --with=test,factory,observer,enum
The workflow tests:
module:create and verify file creationVersion 4.2 includes breaking changes focused on Laravel 12+ support:
Update PHP Version
# Ensure PHP 8.2+ is installed
php -v
Update Laravel Version
# Upgrade to Laravel 12+
composer require laravel/framework:^12.0
Update Package
# Update to v4.x
composer require ngodingskuyy/laravel-module-generator:^4.2
Update Spatie Permission
# Update to v6.x if not already
composer require spatie/laravel-permission:^6.0
Clear and Rebuild
composer dump-autoload
php artisan config:clear
php artisan cache:clear
We welcome contributions! Please feel free to submit a Pull Request.
git clone https://github.com/yourusername/laravel-module-generatorcomposer install./vendor/bin/phpunitvendor/bin/phpunit)MIT ยฉ 2025 NgodingSkuyy
Laravel Module Generator v4.2 - Focused on Laravel 12+, Enhanced with Comprehensive Testing, Built for Modern PHP Development