PHPackages                             mohsen-mhm/code-generator - 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. mohsen-mhm/code-generator

ActiveLibrary[Framework](/categories/framework)

mohsen-mhm/code-generator
=========================

Advanced code generator for Laravel with Livewire 3 support

1.0.0(1y ago)215MITPHPPHP ^8.1

Since Mar 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Mohsen-mhm/code-generator)[ Packagist](https://packagist.org/packages/mohsen-mhm/code-generator)[ RSS](/packages/mohsen-mhm-code-generator/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Code Generator
======================

[](#laravel-code-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3dd10ce4e12d0975efccd1d82da366d83094dd7005ac3501d56b3e24e79916d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f6873656e2d6d686d2f636f64652d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mohsen-mhm/code-generator)[![Total Downloads](https://camo.githubusercontent.com/a2f5aa909b9dfb8a90856075470a8ed50759f59b1cbaa82fd587689dd5ba7800/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f6873656e2d6d686d2f636f64652d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mohsen-mhm/code-generator)[![License](https://camo.githubusercontent.com/65fc78c62cbc782ae5646bfa4c9345467cddc0e4515240285dcd3575e166a1fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6f6873656e2d6d686d2f636f64652d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mohsen-mhm/code-generator)

An advanced code generator for Laravel applications with Livewire 3 support. Rapidly build your Laravel applications by generating models, migrations, controllers, Livewire components, API resources, and tests with a single command.

🚀 Features
----------

[](#-features)

- **Complete CRUD Generation**: Generate all components needed for a feature with one command
- **Livewire 3 Support**: Full support for Livewire 3 components with proper form handling
- **Schema-Based Generation**: Define your database structure in a simple string format
- **API Ready**: Built-in support for API resources and API controllers
- **Testing Support**: Automatically generates both feature and unit tests
- **Customizable Templates**: All stubs can be published and customized
- **Comprehensive Components**:
    - Models with fillable attributes and casts
    - Database migrations
    - Controllers (web and API)
    - Livewire components with validation
    - API resources
    - Feature and unit tests

📋 Requirements
--------------

[](#-requirements)

- PHP 8.1 or higher
- Laravel 10.0 or higher

📦 Installation
--------------

[](#-installation)

You can install the package via composer:

```
composer require mohsen-mhm/code-generator
```

The package will automatically register its service provider.

⚙️ Configuration
----------------

[](#️-configuration)

You can publish the configuration file with:

```
php artisan vendor:publish --tag=code-generator-config
```

This will create a `config/code-generator.php` file where you can customize the behavior of the generator.

If you want to customize the stub files, you can publish them with:

```
php artisan vendor:publish --tag=code-generator-stubs
```

🔧 Usage
-------

[](#-usage)

### Basic Usage

[](#basic-usage)

Generate a complete CRUD setup for a model:

```
php artisan generate User --schema="name:string,email:string:unique,password:string" --all
```

This will generate:

- A User model
- A migration for the users table
- A UserController
- A UserResource for API responses
- A User Livewire component
- Tests for the User model

### Available Commands

[](#available-commands)

#### Generate Everything

[](#generate-everything)

```
php artisan generate {name} --schema="field1:type1,field2:type2:modifier" --all
```

#### Generate Model

[](#generate-model)

```
php artisan generate:model {name} --schema="field1:type1,field2:type2:modifier"
```

#### Generate Controller

[](#generate-controller)

```
php artisan generate:controller {name} --model=ModelName --api
```

#### Generate Livewire Component

[](#generate-livewire-component)

```
php artisan generate:livewire {name} --schema="field1:type1,field2:type2:modifier" --model=ModelName
```

#### Generate Migration

[](#generate-migration)

```
php artisan generate:migration {name} --schema="field1:type1,field2:type2:modifier" --table=table_name
```

#### Generate API Resource

[](#generate-api-resource)

```
php artisan generate:resource {name} --schema="field1:type1,field2:type2:modifier" --collection
```

#### Generate Tests

[](#generate-tests)

```
php artisan generate:test {name} --model=ModelName --feature
```

#### Generate Routes

[](#generate-routes)

```
php artisan generate:routes {name} --api
```

This will add resource routes to your web.php or api.php file.

#### Rollback Generated Files

[](#rollback-generated-files)

```
php artisan generate:rollback {name} --all
```

This will delete all files generated for a specific model. You can also selectively delete specific components:

```
php artisan generate:rollback {name} --model --controller --migration
```

Available options:

- `--all`: Delete all generated files
- `--model`: Delete the model
- `--controller`: Delete the controller
- `--migration`: Delete the migration
- `--factory`: Delete the factory
- `--resource`: Delete API resources
- `--livewire`: Delete Livewire components
- `--test`: Delete tests
- `--routes`: Remove routes from route files
- `--force`: Skip confirmation prompt

### Schema Format

[](#schema-format)

The schema format follows a simple pattern:

```
field_name:field_type:modifier1:modifier2

```

For example:

```
name:string,email:string:unique,age:integer:nullable,is_active:boolean:default:true

```

#### Available Field Types

[](#available-field-types)

- `string`
- `integer`, `bigInteger`, `tinyInteger`, `smallInteger`, `mediumInteger`
- `float`, `double`, `decimal`
- `boolean`
- `date`, `dateTime`, `time`, `timestamp`
- `text`, `mediumText`, `longText`
- `json`, `jsonb`
- And more standard Laravel migration column types

#### Available Modifiers

[](#available-modifiers)

- `nullable`
- `unique`
- `index`
- `default:{value}`
- `comment:{text}`

🛠️ Configuration Options
------------------------

[](#️-configuration-options)

### Namespace Configuration

[](#namespace-configuration)

```
'namespace' => 'App',
```

### Path Configuration

[](#path-configuration)

```
'paths' => [
    'models' => app_path('Models'),
    'controllers' => app_path('Http/Controllers'),
    'livewire' => app_path('Livewire'),
    'migrations' => database_path('migrations'),
    'resources' => app_path('Http/Resources'),
    'tests' => base_path('tests'),
],
```

### Model Options

[](#model-options)

```
'models' => [
    'timestamps' => true,
    'soft_deletes' => false,
    'fillable' => true,
    'casts' => true,
    'relationships' => true,
],
```

### Livewire Options

[](#livewire-options)

```
'livewire' => [
    'version' => 3,
    'include_tests' => true,
    'include_views' => true,
],
```

🎨 Customizing Stubs
-------------------

[](#-customizing-stubs)

After publishing the stubs, you can find them in `resources/stubs/vendor/code-generator`. Modify them to match your project's coding style and requirements.

📝 Examples
----------

[](#-examples)

### Generate a Blog Post Model with All Components

[](#generate-a-blog-post-model-with-all-components)

```
php artisan generate Post --schema="title:string,content:text,published_at:timestamp:nullable,user_id:foreignId" --all
```

### Generate a Product API

[](#generate-a-product-api)

```
php artisan generate Product --schema="name:string,description:text,price:decimal:8,2,stock:integer,category_id:foreignId" --api --all
```

### Generate a Livewire Component for Comments

[](#generate-a-livewire-component-for-comments)

```
php artisan generate:livewire CommentManager --schema="content:text,user_id:foreignId,post_id:foreignId" --model=Comment
```

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

🙏 Credits
---------

[](#-credits)

- [Mohsen](https://github.com/mohsen-mhm)
- [All Contributors](../../contributors)

This package is inspired by the need to rapidly scaffold Laravel applications with modern best practices.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance46

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

419d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7891a1269e2d058cae6f43ce453ca6716c0d4e9aef74ac5ab3d4c454c43b14d?d=identicon)[Mohsen-mhm](/maintainers/Mohsen-mhm)

---

Top Contributors

[![Mohsen-mhm](https://avatars.githubusercontent.com/u/67678628?v=4)](https://github.com/Mohsen-mhm "Mohsen-mhm (50 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mohsen-mhm-code-generator/health.svg)

```
[![Health](https://phpackages.com/badges/mohsen-mhm-code-generator/health.svg)](https://phpackages.com/packages/mohsen-mhm-code-generator)
```

###  Alternatives

[laravel/ui

Laravel UI utilities and presets.

2.7k134.9M601](/packages/laravel-ui)[laravel/breeze

Minimal Laravel authentication scaffolding with Blade and Tailwind.

3.0k31.3M148](/packages/laravel-breeze)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[laravel/sail

Docker files for running a basic Laravel application.

1.9k186.9M1.0k](/packages/laravel-sail)[laravel/wayfinder

Generate TypeScript representations of your Laravel actions and routes.

1.7k4.1M69](/packages/laravel-wayfinder)[laravel/jetstream

Tailwind scaffolding for the Laravel framework.

4.1k19.8M136](/packages/laravel-jetstream)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
