Search by

tgozo / laravel-codegen

A Laravel Code Generator to help you get started with a lot of staff including generating Migrations, Models, Controllers, Factories, Routes, Views, Database Seeders and Request Validation Rules.

Maintainers

Package info

github.com/tgozo19/laravel-codegen

pkg:composer/tgozo/laravel-codegen

Transparency log

Statistics

Installs: 187

Dependents: 0

Suggesters: 0

Stars: 13

Open Issues: 0

v1.1.1 2026-08-17 10:14 UTC

This package is auto-updated.

Last update: 2026-08-17 10:32:51 UTC


README

Latest Version on Packagist Total Downloads License

Stop writing boilerplate code. Start building features.

Laravel CodeGen is a production-grade code generation suite that transforms your development workflow by automatically scaffolding complete, tested, production-ready Laravel components with terminal prompts, interactive wizards, modern frontend templates (Vue 3, React TSX, Inertia, Blade, Livewire), and domain-driven design support.

โœจ Key Capabilities

  • ๐Ÿƒโ€โ™‚๏ธ 10x Faster Scaffolding: Scaffolds complete CRUD modules in seconds with zero configuration.
  • ๐Ÿช„ Interactive Scaffolding Wizard: Run php artisan codegen:wizard for interactive prompt-guided generation.
  • ๐ŸŽจ Modern Frontend Support: Built-in support for Inertia.js Vue 3, Inertia.js React (TSX), Blade, Livewire, and TypeScript definitions.
  • ๐Ÿฐ Domain-Driven Design (DDD): Use --domain=DomainName to structure modules cleanly into domain namespaces.
  • ๐Ÿ“ Form Requests & Backed Enums: Auto-infer validation rules (--requests) and scaffold PHP 8.1+ String Enums (--enum).
  • ๐Ÿ›ก๏ธ Repository Pattern: Scaffold decoupled repository interfaces and Eloquent implementations (--repository).
  • โšก Domain Events & Listeners: Scaffold model lifecycle events and listener classes (--events).
  • ๐Ÿ“„ OpenAPI 3.0 Spec Generator: Generate openapi.json specs automatically (php artisan codegen:openapi).
  • ๐Ÿ”„ Reverse Engineering Magic: Convert existing database tables into models, migrations, and controllers (php artisan codegen:reverse-engineer).
  • ๐Ÿงน Cleanup & Rollback: Safely remove all generated module artifacts with php artisan codegen:clean {Model}.
  • ๐Ÿ“‘ Publishable Stubs: Customize generated code templates using php artisan codegen:publish-stubs.
  • ๐Ÿงช Pest PHP Test Suite: Auto-generates comprehensive Pest PHP feature tests out of the box.

๐Ÿ“ฆ Installation

Install via Composer:

composer require tgozo/laravel-codegen --dev

The package auto-registers its service provider. No extra setup required!

Optional: Publish Configuration & Custom Stubs

# Publish config file
php artisan vendor:publish --tag="laravelcodegen-config"

# Publish customizable stubs to resources/stubs/vendor/laravelcodegen
php artisan codegen:publish-stubs

๐Ÿš€ Quick Start & CLI Usage

๐Ÿง™โ€โ™‚๏ธ Interactive Terminal Wizard

Run the interactive wizard powered by Laravel Prompts:

php artisan codegen:wizard

โšก Scaffolding Command Flags

# Complete CRUD module with Vue 3 Inertia, Form Requests, and Pest Tests
php artisan make:codegen-migration create_articles_table --all --inertia --requests -p

# Complete DDD module with React TSX, TypeScript definitions, and Enums
php artisan make:codegen-migration create_products_table --all --react --types --enum=ProductStatus:draft,published --domain=Catalog

# Dry Run / Preview mode (simulates generation without creating files)
php artisan make:codegen-migration create_orders_table --all --dry-run

Command Flag Reference

Option Description
-m, --model Generate Eloquent Model with casts() and relationships
-c, --controller Generate RESTful Controller
-f, --factory Generate Model Factory with smart faker matching
-s, --seeder Generate Database Seeder
-p, --pest Generate Pest PHP feature test suite
-l, --livewire Generate Livewire components
--inertia Generate Vue 3 Inertia pages (Index.vue, Create.vue)
--react Generate React TSX Inertia pages (Index.tsx, Create.tsx)
--types Generate TypeScript definition (resources/js/types/{Model}.d.ts)
--requests Generate Store{Model}Request.php & Update{Model}Request.php
--enum=Name:case1,case2 Generate PHP 8.1+ Backed String Enum
--repository Generate Repository contract and Eloquent implementation
--events Generate App\Events\{Model}Created.php and Handle{Model}Created.php
--soft-deletes-actions Include restore() and forceDelete() controller methods
--domain=Name Scope generated files to domain path (DDD)
--dry-run Preview generated files without writing to disk
--all Generate complete module suite
--force Overwrite existing files

๐Ÿ› ๏ธ Specialized Commands

๐Ÿ”„ Reverse Engineer Existing Database

Convert an existing database table or schema into models and migrations:

# Reverse engineer all database tables
php artisan codegen:reverse-engineer --all

# Target specific tables
php artisan codegen:reverse-engineer --tables=users,orders --all

๐Ÿ“„ OpenAPI 3.0 Spec Generator

Generate OpenAPI 3.0 JSON specification for frontend clients and Postman:

php artisan codegen:openapi --output=openapi.json

๐Ÿงน Module Rollback & Cleanup

Safely inspect and delete all generated files for a specific module:

php artisan codegen:clean Article

๐Ÿ“ฆ Migration Squashing & Combining

Merge multiple incremental migrations into a single clean base migration file:

# Squash migrations for a single table
php artisan make:codegen-squash products

# Combine modifier migrations
php artisan codegen:combine-migrations --table=users

๐Ÿงช Running Package Tests

The package features a complete Pest PHP test suite built on Orchestra Testbench:

cd the-package
./vendor/bin/pest tests

๐Ÿ“ˆ Roadmap & Completed Features

  • API Documentation - Auto-generate OpenAPI/Swagger 3.0 spec (codegen:openapi)
  • Event/Listener System - Auto-generate domain events and listeners (--events)
  • TypeScript Integration - Auto-generate TypeScript interface definitions (--types)
  • React & Vue Support - Auto-generate Inertia Vue 3 & React TSX pages (--inertia, --react)
  • Repository Pattern - Auto-generate repository contracts & Eloquent implementations (--repository)
  • Interactive Terminal Wizard - Laravel Prompts guided workflow (codegen:wizard)
  • Custom Stubs Loader - Publish & customize package stubs (codegen:publish-stubs)
  • Docker Integration - Scaffolding custom Docker configurations
  • Multi-tenancy Support - Scaffolding tenant-aware models and migrations

๐Ÿ›ก๏ธ Security

If you discover any security-related issues, please email dev@tgozo.co.zw instead of using the issue tracker.

๐Ÿ“„ License

The MIT License (MIT). Please see License File for more information.

๐Ÿ™ Credits

  • Takudzwa Gozo - GitHub
  • All Contributors - Thank you for making this package better!

โญ If this package saved you time, please consider giving it a star on GitHub! โญ

Report Bug โ€ข Request Feature