Download the PHP package nahid-ferdous/laravel-module-generator without Composer
On this page you can find all versions of the php package nahid-ferdous/laravel-module-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nahid-ferdous/laravel-module-generator
More information about nahid-ferdous/laravel-module-generator
Files in nahid-ferdous/laravel-module-generator
Package laravel-module-generator
Short Description Speeds up Laravel development by automating repetitive tasks. This package helps to generate module files (service, controller, model, migration, resource, request, collection) from YAML file.
License MIT
Homepage https://github.com/nahidnfr123/laravel-module-generator
Informations about the package laravel-module-generator
Laravel Module Generator
📖 Introduction
A developer-friendly Laravel package to generate complete modules (Model, Migration, Controller, Service, Resource, Collection, Form Request, and Routes) from a single YAML configuration file. Now includes Authentication (Sanctum & Passport) & User Management, Postman collection generation, and DB diagram export for streamlined API development and documentation.
✨ Features
- Generate full Laravel modules from YAML configuration
- 🆕 Built-in Authentication & User Management
- 🆕 Roles & Permissions Management (Spatie Integration)
- Customizable stub support (with fallback to internal defaults)
- Postman collection generation for instant API testing
- Database diagram export compatible with dbdiagram.io
- Generates:
- Models with relationships
- Database migrations
- API Controllers
- Service classes
- Form Request validation
- API Resources & Collections
- Route entries
- Authentication System
- User Management System
- Roles & Permissions System
- Postman collection files
- DB diagram files (.dbml)
- Smart fillable and relationship handling
- Designed for rapid development and prototyping
🚀 Installation
Install the package via Composer:
Setup
Generate required files and configurations:
Or force install if you've already executed the command:
What Gets Generated
- Useful Traits →
app/Traits/ - Global Exception Handler →
app/Exceptions/ExceptionHandler.php - Helper Functions →
app/Helpers/ - Middleware (CORS & Auth) →
app/Http/Middleware/ - Configuration →
module/modules.yaml
Optional: Publish Config & Stubs
Customize the package defaults by publishing configuration and stubs:
This creates:
config/module-generator.phpmodule/stub/directory
🔐 Authentication & User Management
Prerequisites: Configure your
.envDB connection before generating the authentication module.
Generate Auth System
Create a complete authentication system with a single command:
Available Options:
What Gets Generated
Authentication Files:
- AuthController & AuthService
- Login, Register, Password Reset Requests
- Email Verification (optional)
- Auth Routes
User Management Files:
- UserController & UserService
- User Requests, Resources & Collections
Roles & Permissions (optional):
- RoleController & PermissionController
- Role & Permission Services
- Spatie Laravel Permissions (auto-installed)
- Permission & User Seeders
Social Authentication (optional):
- SocialAuthController
- Laravel Socialite (auto-installed)
API Endpoints
Authentication:
User Management:
Roles & Permissions:
Social Authentication:
Setup Instructions
1. Choose Authentication Guard (Sanctum or Passport)
Sanctum (Recommended for Single-Page Apps):
Update bootstrap/app.php:
Passport (For Third-Party Clients):
2. Update User Model
For Sanctum:
For Passport:
For Roles & Permissions:
3. Update Configuration Files
.env:
config/auth.php:
4. Register Routes
Update routes/api.php:
5. Configure Social Providers (Optional)
Update config/services.php:
6. Seed Initial Data
database/seeders/DatabaseSeeder.php:
Run:
🛠️ Module Generation from YAML
Quick Start
Generate a complete module set (Model, Migration, Controller, Service, Resource, Collection, Form Request, Routes) from a single YAML file.
Default YAML location: module/models.yaml
Use custom file:
YAML Configuration Guide
Minimal Example
Complete Example
Generation Commands
Main Command: module:generate
Generate complete API modules from YAML schema.
Signature:
Examples:
Database Diagram: dbdiagram:generate
Export your YAML schema as DBML for visualization.
Signature:
Examples:
Use dbdiagram.io to visualize and export diagrams.
Postman Collection: postman:generate
Generate a Postman collection for API testing.
Signature:
Examples:
DBML to YAML: dbdiagram:import
Convert existing DBML files to YAML format.
Signature:
Workflow:
- Design schema at dbdiagram.io
- Export DBML
- Save to
.dbmlfile - Run import command
- Review and use generated YAML
Rollback: module:rollback
Restore to a previous generation state using automatic backups.
Signature:
Examples:
YAML Field Types & Modifiers
Supported Types:
- String:
string,text,longText - Numeric:
integer,bigInteger,double,float,decimal - Boolean:
boolean - Date/Time:
date,dateTime,timestamp,time - Files:
image,file(auto-handles uploads) - JSON:
json - Enum:
enum - Foreign Keys:
foreignId:table_name - Soft Deletes:
deleted_at: dateTime:nullable
Common Modifiers:
nullable— Column can be nullunique— Add unique constraintdefault <value>— Set default value
Field Examples:
Relationships
Format: relationType: Model:functionName, Model:functionName
Supported Types:
belongsTo— Many-to-onehasMany— One-to-manyhasOne— One-to-onebelongsToMany— Many-to-many
Examples:
Special Mapping:
creator→created_byfieldupdater→updated_byfieldparent→parent_idfield
Generation Control
Control Options:
generate: all— Generate all componentsgenerate_only: model, migration— Only these componentsgenerate_except: seeder— All except thesenested_requests: variants, images— Include in Postman bodies
Valid Components:
model, migration, controller, service, request, resource, collection, seeder
Compound Unique Constraints:
Output Locations
- Models:
app/Models/ - Migrations:
database/migrations/ - Controllers:
app/Http/Controllers/ - Services:
app/Services/ - Requests:
app/Http/Requests/ - Resources:
app/Http/Resources/ - Collections:
app/Http/Resources/ - Seeders:
database/seeders/ - Routes: Appended to
routes/api.php - Postman:
module/postman_collection.json - DBML:
module/dbdiagram.dbml - Backups:
module/backups/{timestamp}/
Troubleshooting
Auth Module Conflicts:
If you ran auth:generate previously, set User.generate_only: seeder in YAML to avoid overwriting custom auth code.
Migration Issues: Use new migrations to alter existing tables rather than editing previously-applied migrations.
Foreign Key Naming:
Ensure foreignId:table values match your actual table names.
File Uploads:
Models with image or file fields automatically generate form-data Postman requests.
Version Control:
Keep your YAML schema in Git and use branches before running --force to make rollbacks easier.
🚀 Complete Workflow
From installation to production-ready API:
1. Generate Authentication (Optional)
2. Create YAML Schema
Create or edit module/models.yaml with your models and fields.
3. Review Generated Files
Review output before running --force.
4. Apply Migrations
5. Test with Postman
Import module/postman_collection.json into Postman and test endpoints.
6. Visualize Database
Copy DBML output to dbdiagram.io for visualization.
7. Local Testing
8. Deploy
Commit changes and deploy:
Following this workflow will help you safely move from YAML schemas to fully-functional API endpoints.
✨ Features Summary
- ✅ Generate complete Laravel modules from YAML
- ✅ Authentication & User Management (Sanctum & Passport)
- ✅ Roles & Permissions (Spatie Integration)
- ✅ Social Authentication (OAuth)
- ✅ Postman collection generation
- ✅ Database diagram export (DBML)
- ✅ Automatic backups & rollback support
- ✅ Customizable stubs
- ✅ Smart fillable and relationship handling
- ✅ File upload handling for image/file fields
🚀 Roadmap
- [ ] GUI for YAML configuration
- [ ] OpenAPI/Swagger documentation generation
- [ ] Insomnia collection export
- [ ] GraphQL schema generation
- [ ] Two-Factor Authentication (2FA)
- [ ] Additional relationship types
📝 Recent Updates
v1.3.00
- ✅ IMPROVED: YAML file structure and options
- ✅ NEW: Database to Models YAML conversion
v1.2.50
- ✅ NEW: Passport support added
- ✅ IMPROVED: Better error handling and user feedback
v1.2.0
- ✅ NEW: Authentication system generation
- ✅ NEW: User management system
- ✅ NEW: Roles & Permissions with Spatie integration
v1.0.10
- ✅ NEW: Postman collection generation
- ✅ NEW: Database diagram export
- ✅ NEW: Selective component generation
Happy generating! 🎉