salmanzafar/laravel-crud-generator
A Laravel package that scaffolds full CRUD operations from your database tables, generating models, controllers, views, routes, and migrations so you can skip repetitive boilerplate and get admin panels or resource management built faster.
Install the package via Composer:
composer require salmanzafar949/laravel-crud-generator
On Laravel 5.5+ the service provider is auto-discovered. On older 5.x projects register Salmanzafar949\CrudGenerator\CrudGeneratorServiceProvider in config/app.php manually.
Publish the package assets so you can inspect and tweak the config (and any publishable stubs):
php artisan vendor:publish --provider="Salmanzafar949\CrudGenerator\CrudGeneratorServiceProvider"
Look here first after install:
php artisan list — filter for crud/generate to confirm which command signature the installed version exposes (the package has been renamed/updated across releases, so the exact verb varies).config/crud-generator.php or similar) — this holds the paths, stub locations, and namespace conventions.stubs/ directory (either in vendor/ or published) — this is where every generated file's shape is defined.First use case — scaffold a single resource end-to-end:
php artisan crud:generate Post --fields="title:string,body:text,published:boolean"
This typically emits a migration, Eloquent model, resource(ful) controller, blade views, and a route snippet. Run php artisan migrate, wire the route into routes/web.php if not auto-appended, and you have a working CRUD screen in under five minutes. Start with a throwaway model (e.g. Post) to see exactly what the package emits before pointing it at anything real.
Field-definition strings are the core contract. Most usage hinges on a --fields option like name:string, price:decimal(8,2), user_id:foreign. Get comfortable with the syntax by scaffolding a scratch resource and reading the resulting migration — the migration is the source of truth for what the generator understood.
Generate → migrate → harden → fork. Treat generation as a first pass, not an ongoing source of truth. The practical workflow is: generate, migrate, then immediately commit the generated files to your VCS and start hand-editing controllers for authorization ($this->authorize(...)), FormRequest validation, and pagination. Once you've edited a controller, never re-run the generator against that model.
Customize the stubs, not the output. If every controller needs $this->authorize() calls or a dataTable() JSON endpoint, publish the stubs and edit them once. That way every future crud:generate produces code aligned with your house style, and you avoid re-editing boilerplate per resource.
Layer it with existing conventions. If your project already has a BaseController, a repository layer, or standardized blade layouts, edit the controller and view stubs to extend those classes and use your layout. The generator becomes a thin wrapper around your conventions rather than a foreign code style.
Use it for internal/admin scaffolding, not customer-facing models. The generated controllers are intentionally plain — no policies, no soft deletes, no authorization gates. They're ideal for back-office tools, prototypes, and feature-branch spikes; less ideal as a starting point for a public-facing API.
Batch pattern for multi-model projects. Run the generator in a single session against several models, then do one combined review/migration pass. This mirrors how make:model -m -c -r is used and keeps the migration timestamps orderly.
Route wiring. If the generator doesn't auto-register routes, add Route::resource('posts', PostController::class) yourself immediately after generation and run php artisan route:list to confirm binding.
Laravel 5/6 only. The composer.json constraint almost certainly caps at Laravel 6 (^5.5|^6.0). Installing on Laravel 8/9/10 will either fail dependency resolution or succeed but generate code that references removed helpers (e.g. str_slug, array_get, facade aliases). Check composer show salmanzafar949/laravel-crud-generator and its require block before assuming compatibility; if you're on modern Laravel, you'll likely need to fork and update stub syntax.
Low stars and no dependents means no safety net. With 23 stars and zero dependent packages, treat every release as unvetted. Pin the exact version in composer.json, and audit the generated output the first time you use any new version. Bugs will not be fixed upstream quickly — be prepared to patch stubs yourself (which is why publishing stubs matters).
Regeneration overwrites. Running the command against an existing model will clobber your hand-edited controller/views. Always commit before generating, and diff afterward. If the tool is destructive in your version, consider running it in a scratch branch.
Naming and namespace assumptions. Generators commonly assume App\Http\Controllers, App\Models, and pluralized table names. If your project uses App\Domains\... or singular table names, the generated use statements will be wrong. Adjust the config's namespace/path keys before first use, or fix stubs.
Migration correctness is your job. Complex column types (JSON, point, enum, composite indexes, foreign-key constraints with onDelete) are rarely expressible in a --fields string. After generation, open the migration and add constraints, indexes, and FK behavior by hand — the generator's default is usually bare string()/integer().
Validation is thin. Generated controllers typically only validate a subset of fields or not at all. Add a FormRequest per resource; don't trust the boilerplate to guard mass-assignment or required fields. Check the model's $fillable too — generators often include every field, which is a mass-assignment risk if you later expose the model to an API.
Debugging tip: read the stub before reading the output. When the generated file surprises you, diff it against the stub in vendor/salmanzafar949/laravel-crud-generator/src/stubs/. The delta tells you which substitution token (model name, fields, namespace) behaved unexpectedly. php artisan vendor:publish --tag=crud-stubs (or the equivalent tag) copies stubs locally so you can edit and re-test in isolation.
Extension point: post-generation events/hooks. If the package fires an event (or supports a config after_generate callback), use it to auto-register routes, run pint, or append a policy stub — that's cleaner than remembering manual follow-ups each time. If no hook exists, wrap the command in your own Artisan command that shells out to the generator and does the post-processing.
Beware blade view output. Generated views are typically Bootstrap 4-era markup with @extends('layouts.app'). If you use Tailwind, Livewire, or a different layout name, edit the view stubs before bulk-generating — otherwise you'll be rewriting every view by hand and lose the time-saving benefit.
When not to use it. For a single model, php artisan make:model -mcr plus your existing patterns is often faster than debugging a package with a small community. Use this generator when you're scaffolding five or more resources at once, or when you've invested in custom stubs that match your codebase — that's where the leverage is real.
How can I help you explore Laravel packages today?