PHPackages                             tgozo/laravel-codegen - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. tgozo/laravel-codegen

ActiveLibrary[Framework](/categories/framework)

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.

1.0.10(5mo ago)131821MITPHP

Since Aug 10Pushed 5mo ago6 watchersCompare

[ Source](https://github.com/tgozo19/laravel-codegen)[ Packagist](https://packagist.org/packages/tgozo/laravel-codegen)[ RSS](/packages/tgozo-laravel-codegen/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (14)Used By (0)

🚀 Laravel CodeGen - The Ultimate Laravel Development Accelerator
================================================================

[](#-laravel-codegen---the-ultimate-laravel-development-accelerator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/33eda2d9931b00db7e0fce71c0f114562583278cefd85d8e5c6e54c2a293bf1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74676f7a6f2f6c61726176656c2d636f646567656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tgozo/laravel-codegen)[![Total Downloads](https://camo.githubusercontent.com/ed426104aba4df00029cf90f181fcfc2a28b5ba249155f7d0c86e21180114207/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74676f7a6f2f6c61726176656c2d636f646567656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tgozo/laravel-codegen)[![License](https://camo.githubusercontent.com/eaf3303e502720b27a45de63da4b5fac656ef15fd72fbd710ca2fd4d68cadb5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74676f7a6f2f6c61726176656c2d636f646567656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tgozo/laravel-codegen)

**Stop writing boilerplate code. Start building features.**

Laravel CodeGen is a powerful code generation package that transforms your development workflow by automatically generating complete, production-ready Laravel components with a single command. Say goodbye to repetitive coding and hello to blazing-fast development!

✨ Why Laravel CodeGen?
----------------------

[](#-why-laravel-codegen)

- **🏃‍♂️ 10x Faster Development**: Generate complete CRUD operations in seconds, not hours
- **🎯 Zero Configuration**: Works out of the box with sensible defaults
- **🔧 Highly Configurable**: Customize every aspect of generated code to match your standards
- **🧪 Test-Driven**: Automatically generates comprehensive Pest PHP tests
- **📱 Modern Stack Support**: Built-in Livewire components with Alpine.js integration
- **🔄 Reverse Engineering**: Convert existing databases to Laravel code instantly
- **🎨 Consistent Code Quality**: Follows Laravel best practices and coding standards

🔥 Features That Will Blow Your Mind
-----------------------------------

[](#-features-that-will-blow-your-mind)

### 🎪 Complete Application Scaffolding

[](#-complete-application-scaffolding)

Generate entire application modules with a single command:

- **📋 Database Migrations** - With intelligent field types and relationships
- **📦 Eloquent Models** - Including relationships, casts, and factory integration
- **🎮 Controllers** - Full CRUD operations with proper validation
- **🏭 Model Factories** - Smart fake data generation using AI-powered field detection
- **🌱 Database Seeders** - Pre-populated with realistic test data
- **🚏 Routes** - RESTful routes with proper naming conventions
- **👀 Blade Views** - Beautiful, responsive UI components
- **⚡ Livewire Components** - Modern, reactive components (Create, Read, Update, Delete)
- **🧪 Pest PHP Tests** - Comprehensive test coverage for all endpoints
- **📝 Form Requests** - Robust validation with custom rules

### 🔄 Reverse Engineering Magic

[](#-reverse-engineering-magic)

Already have a database? No problem!

```
# Convert your entire database to Laravel code
php artisan codegen:reverse-engineer --all

# Generate models only
php artisan codegen:reverse-engineer --models

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

**Supports multiple databases**: MySQL, PostgreSQL, SQLite

### 🎨 Smart Code Generation

[](#-smart-code-generation)

- **Intelligent Field Detection**: Automatically detects field types and generates appropriate form inputs
- **Relationship Inference**: Discovers and generates model relationships automatically
- **Faker Integration**: Uses advanced algorithms to generate realistic fake data
- **Validation Rules**: Auto-generates validation rules based on database constraints
- **Consistent Naming**: Follows Laravel naming conventions perfectly

📦 Requirements
--------------

[](#-requirements)

- **PHP** &gt;= 8.1
- **Laravel** &gt;= 10.0
- **Composer** 2.0+

⚡ Quick Installation
--------------------

[](#-quick-installation)

```
composer require tgozo/laravel-codegen
```

**That's it!** The package auto-registers itself. No additional setup required.

### Optional: Publish Configuration

[](#optional-publish-configuration)

```
php artisan vendor:publish --provider="Tgozo\LaravelCodegen\CodeGenServiceProvider"
```

🚀 Usage Examples
----------------

[](#-usage-examples)

### 🎯 Quick Start - Complete CRUD in 30 Seconds

[](#-quick-start---complete-crud-in-30-seconds)

```
# Generate everything for a blog post system
php artisan make:codegen-migration create_posts_table --all
```

**This single command creates:**

- ✅ Migration with intelligent field prompts
- ✅ Post model with relationships and casts
- ✅ PostController with full CRUD operations
- ✅ PostFactory with realistic fake data
- ✅ Database seeder
- ✅ 4 Livewire components (View, Show, Create, Edit)
- ✅ RESTful routes
- ✅ Responsive Blade views
- ✅ Complete Pest PHP test suite (12+ tests)
- ✅ Form request validation

### 🎪 Selective Generation

[](#-selective-generation)

```
# Just migration, model, and factory
php artisan make:codegen-migration create_users_table -mf

# Migration, model, controller, and seeder
php artisan make:codegen-migration create_products_table -mcs

# Everything with Livewire components
php artisan make:codegen-migration create_orders_table -mcsfp --livewire
```

### 🔄 Reverse Engineer Existing Database

[](#-reverse-engineer-existing-database)

```
# Convert entire database
php artisan codegen:reverse-engineer --all

# Only specific tables
php artisan codegen:reverse-engineer --tables=users,posts,comments --models

# With custom connection
php artisan codegen:reverse-engineer --connection=legacy --all
```

### 🎨 Advanced Field Configuration

[](#-advanced-field-configuration)

During migration creation, you can specify complex field types:

```
Field name: title
Field type: string:nullable:unique:index

Field name: price
Field type: decimal:precision:10,2:default:0.00

Field name: user_id
Field type: foreignId:constrained:cascadeOnDelete

```

🛠️ Command Options
------------------

[](#️-command-options)

OptionDescription`-m, --model`Generate Eloquent model`-c, --controller`Generate controller with CRUD operations`-f, --factory`Generate model factory`-s, --seeder`Generate database seeder`-p, --pest`Generate Pest PHP tests`-l, --livewire`Generate Livewire components`--all`Generate everything (equivalent to -mcsfpl)`--force`Overwrite existing files`--relates`Specify model relationships`--except`Exclude specific generations🎭 Generated Code Examples
-------------------------

[](#-generated-code-examples)

### 📦 Eloquent Model

[](#-eloquent-model)

```
