darshan-belani/laravel-crud-generator
Generate full Laravel CRUD modules from one command: migrations, models with relationships, resource/API controllers, Livewire components, and Bootstrap/Tailwind views. Can auto-install Breeze or Laravel UI on fresh apps. Supports Laravel 10+, PHP 8.1+.
composer require darshan-belani/laravel-crud-generator
php artisan vendor:publish --tag=crud
php artisan make:module posts
bootstrap, tailwind, livewire, or api.Quickly scaffold a blog module with API endpoints and Tailwind views:
php artisan make:module blogs tailwind
This generates:
blogs table)Blog with fillable fields)BlogController with store, index, etc.)index.blade.php, create.blade.php, etc.)web.php/api.php# Bootstrap 5 views
php artisan make:module users bootstrap
# Tailwind CSS views
php artisan make:module products tailwind
# Livewire components (Tailwind-based)
php artisan make:module orders livewire
# API-only (no views)
php artisan make:module reports api
# Override default plural slug route
php artisan make:module admin_panels --route=admin
Generates routes like:
Route::resource('admin', AdminPanelController::class);
user_id):
php artisan make:module posts
user_id as a field → Generator prompts for relationship type (e.g., belongsTo).Post model and foreign key in migration.For multiple modules (e.g., posts, comments, users):
# Loop through modules in a script
php artisan make:module posts tailwind
php artisan make:module comments tailwind
composer require laravel/breeze --dev
php artisan breeze:install
// app/Livewire/Posts/Index.php
public function mount() {
$this->posts = Post::latest()->get();
}
Http tests:
public function test_create_post() {
$response = $this->post('/api/posts', [
'title' => 'Test Post',
'body' => 'Content...'
]);
$response->assertCreated();
}
php artisan vendor:publish --tag=stubs-crud
resources/stubs/.config/crud.php:
'stub_path' => resource_path('stubs/'),
Migration Conflicts
.gitignore for database/migrations/).Livewire Component Naming
Index, Create, Edit, Show but must match route names.Index component handles GET /posts (not GET /posts/index).API vs. Web Route Duplication
Route::resource (web) and Route::apiResource (API) for non-API stacks.--route flag or manually remove duplicates in routes/api.php.Tailwind/Livewire Dependencies
tailwind.config.js).npm install and npx tailwindcss build if styles are missing.Eloquent Relationship Assumptions
belongsTo for foreign keys but no inverse relationships (e.g., hasMany).laravel/prompts is installed (composer require laravel/prompts).php artisan view:clear
php artisan route:list for duplicates. Use php artisan route:clear if needed.Field Validation
FormRequest classes include basic validation (e.g., required|string).app/Http/Requests:
public function rules() {
return [
'title' => 'required|string|max:255',
'body' => 'required|string',
];
}
Partial Generation
api stack, then manually create Blade files later.Relationship Handling
hasMany/belongsToMany, define relationships in the model after generation:
public function comments() {
return $this->hasMany(Comment::class);
}
Testing Generated Code
Feature tests:
public function test_list_posts() {
$response = $this->get('/posts');
$response->assertStatus(200);
}
Performance Optimization
index():
return Post::paginate(15);
wire:model.live for real-time updates.Customizing Stubs
tailwind/form.blade.php to add error messages:
@error($field)
<div class="text-red-500">{{ $message }}</div>
@enderror
Multi-Tenant Projects
Post model to include tenant logic:
protected static function booted() {
static::addGlobalScope(new TenantScope());
}
Soft Deletes
use SoftDeletes; to the model and regenerate:
use Illuminate\Database\Eloquent\SoftDeletes;
protected $dates = ['deleted_at'];
How can I help you explore Laravel packages today?