Generation commands
Generate a complete module set using the default YAML file:
php artisan module:generate
Key options and examples:
- Overwrite all generated files (use with caution):
php artisan module:generate --force - Use a custom YAML file:
php artisan module:generate --file=custom/path/models.yaml - Skip Postman collection generation:
php artisan module:generate --skip-postman - Skip DB diagram generation:
php artisan module:generate --skip-dbdiagram - Custom Postman settings:
php artisan module:generate \ --postman-base-url=https://api.myapp.com \ --postman-prefix=api/v1
Available CLI Commands
module:generate — Main module generation command
Generate complete API modules (Model, Migration, Controller, Service, Resource, Collection, Form Request, and Routes) from your YAML schema.
Signature:
php artisan module:generate
{--file= : Path to the YAML schema file}
{--force : Overwrite existing files without prompting}
{--skip-backup : Skip creating backups of existing files}
{--skip-postman : Skip Postman collection generation}
{--skip-dbdiagram : Skip DB diagram generation}
{--postman-base-url= : Base URL for Postman requests}
{--postman-prefix= : API prefix for Postman requests}
Options:
--file=path/to/file.yaml— Specify custom YAML file (default:module/models.yaml)--force— Overwrite existing files without confirmation prompt--skip-backup— Skip creating backups (only use if you have Git version control)--skip-postman— Skip Postman collection generation--skip-dbdiagram— Skip DB diagram generation--postman-base-url=http://localhost:8000— Set base URL for Postman collection--postman-prefix=api/v1— Set API prefix for Postman requests
Examples:
# Generate with default settings (will ask before overwriting)
php artisan module:generate
# Generate with custom file and force overwrite
php artisan module:generate --file=schemas/products.yaml --force
# Generate everything with custom Postman settings
php artisan module:generate \
--postman-base-url=https://api.myapp.com \
--postman-prefix=api/v2
# Generate models/migrations only (skip Postman and DB diagram)
php artisan module:generate --skip-postman --skip-dbdiagram
# Generate without creating backups (use if already committing to Git)
php artisan module:generate --force --skip-backup
Tips, gotchas, and troubleshooting
- Auth module conflicts: If you previously ran
php artisan auth:generate, setUser.generate_only: seederin your YAML to avoid overwriting hand-tuned auth scaffolding. - Foreign key naming: Double-check
foreignId:tablevalues — the generator uses the provided table names to wire up migration columns and relations. - Migration conflicts: If a generated migration conflicts with an existing migration, prefer using a new migration to alter the table instead of blindly overwriting.
- Version control: Use Git branches before running
--forceto make it easy to compare and revert changes. - Production safety: Always review generated migrations and validation rules before applying them to production environments.
- Schema versioning: Keep your YAML schema under version control and update it as your data model evolves.
- Backup management: Use
--skip-backuponly if you have Git commits and are comfortable with manual rollbacks. - File uploads: Models with
imageorfilefields automatically generate form-data Postman requests instead of JSON. - Nested requests: Use
nested_requeststo specify which relations should appear in Postman request bodies. This prevents circular reference issues. - Relation naming: Special relation names like
creator,updater,parentautomatically map to the correct foreign keys (created_by,updated_by,parent_id).
Happy generating — once your YAML is shaped the generator handles repetitive boilerplate so you can focus on business logic.