composer require gajjar-mitul/laravel-module-scaffolding
Free to use under its open-source licence. Issues and pull requests are welcome.
View on GitHub ↗Domain-Driven CRUD Generator Package
Overview
A production-ready Composer package that automates end-to-end CRUD module generation for Laravel applications following domain-driven design principles.
Born from frustration with existing scaffolding tools that didn't match real-world architectural preferences, this package generates complete, opinionated modules reflecting a clean, maintainable architecture.
The generator creates full module stacks in seconds—from database migrations and models through controllers, services, query classes, validation layers, Blade views, and class-based JavaScript files—all organised under a domain-oriented namespace structure. Unlike generic scaffolders, it respects your architectural conventions: Spatie Data DTOs as direct method parameters (eliminating FormRequest boilerplate), explicit column selection in query classes for performance, class-based JavaScript modules stored as organised resources, and a cohesive layered architecture pattern.
Active Project: This is a living tool continuously refined based on real-world usage in long-running production applications, with planned expansions for multiple architectural patterns to serve diverse developer preferences.
The hard parts
Every project has a few problems that decide whether it works in real life. These were the ones here, and how we handled them.
Creating a generator that enforces good architectural practices without being overly rigid or one-size-fits-all
Built configuration-driven stubs with a publishable override system, allowing developers to customise templates while maintaining core conventions (DDD structure, service layer pattern, query objects)
Supporting both FormRequest and Spatie Data DTO validation approaches without code duplication
Implemented validation abstraction layer with switchable stub generation, allowing DTOs to be passed directly as method arguments (your preferred pattern)
Accommodating multiple field definition methods (existing tables, YAML definitions, interactive prompts) without complex logic
Implemented priority-based resolution strategy: existing schema → YAML file → interactive prompts, giving developers a choice while maintaining sensible defaults
Generating class-based JavaScript modules that integrate seamlessly with Vite compilation and production minification
Generated JavaScript files as organised class-based modules stored in the resources folder with Vite configuration compatibility for centralised compilation via app.blade.php
Supporting Laravel 10, 11, 12, and 13 with different feature sets and API changes
Abstracted version-specific behaviour through configuration and tested against all supported versions with CI pipeline validation
Allowing developers to customise code generation while maintaining package upgradability
Implemented a publishable stub system where only modified stubs are used; unmodified stubs fall back to package defaults
Preventing N+1 queries and forcing developers to think about data access patterns
Generated Query classes with explicit column selection enforcement (configurable), making data access intentions clear in the codebase
Under the hood
composer require gajjar-mitul/laravel-module-scaffolding
Free to use under its open-source licence. Issues and pull requests are welcome.
View on GitHub ↗