PHPackages                             devkits/module-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. devkits/module-generator

ActiveLibrary[Framework](/categories/framework)

devkits/module-generator
========================

Generate controller, model, view and migration for a Laravel module in one command

v1.1.0(1y ago)011MITPHPPHP ^7.4|^8.0|^8.1|^8.2|^8.3

Since Mar 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/christophervistal25/maintenance-generator)[ Packagist](https://packagist.org/packages/devkits/module-generator)[ RSS](/packages/devkits-module-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Laravel Module Generator
========================

[](#laravel-module-generator)

A powerful Laravel package to generate a complete module (Controller, Model, and Migration) with a single artisan command. Streamline your development workflow and maintain consistency across your application.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require devkits/module-generator
```

Auto-Discovery
--------------

[](#auto-discovery)

This package supports Laravel's auto-discovery feature. After you install it, the service provider will be automatically registered, and you can start using the package right away without any additional configuration.

For Laravel versions before 5.5 (which is unlikely since this package requires Laravel 8.0+), you would need to manually add the service provider to your `config/app.php` file:

```
'providers' => [
    // Other service providers...
    DevKits\ModuleGenerator\ServiceProvider::class,
],
```

Basic Usage
-----------

[](#basic-usage)

```
php artisan make:module Blog
```

This simple command will create:

- A `Blog` model in `app/Models/`
- A `BlogController` in `app/Http/Controllers/`
- A migration file for the `blogs` table
- A factory file for the model

Advanced Usage
--------------

[](#advanced-usage)

### Field Generation

[](#field-generation)

Generate a module with specific fields:

```
php artisan make:module Product --fields="name:string,price:decimal,description:text,in_stock:boolean"
```

This will create:

- A `Product` model with `name`, `price`, `description`, and `in_stock` as fillable fields
- A migration with the appropriate columns and types
- A `ProductController` with CRUD methods
- A factory with appropriate faker methods for each field type

### Select/Dropdown Fields

[](#selectdropdown-fields)

Define fields that should be rendered as select/dropdown menus with predefined options:

```
php artisan make:module Employee --fields="name:string,email:string,hire_date:date" --selects="department:engineering,marketing,sales,hr;status:active,on_leave,terminated"
```

This will:

- Add `department` and `status` as enum fields in the migration
- Add constants in the model for the dropdown options
- Add validation rules in the controller
- Prepare the controller to pass options to views

The generated model will include constants for the select options:

```
class Employee extends Model
{
    // ...

    // Select options for fields
    public const DEPARTMENT_OPTIONS = ['engineering', 'marketing', 'sales', 'hr'];
    public const STATUS_OPTIONS = ['active', 'on_leave', 'terminated'];
}
```

### API Controllers

[](#api-controllers)

Generate API-focused controllers that return JSON responses:

```
php artisan make:module User --api
```

Or:

```
php artisan make:module User --type=api
```

### Generate Views

[](#generate-views)

```
php artisan make:module Comment --views
```

This creates Blade views for:

- Index (listing)
- Create form
- Edit form
- Show/detail page

### Module Directory Structure

[](#module-directory-structure)

Create modules in a dedicated directory structure:

```
php artisan make:module Order --module-style
```

This organizes the module in a modular structure:

```
Modules/
  ├── Order/
      ├── Http/
      │   └── Controllers/
      │       └── OrderController.php
      ├── Models/
      │   └── Order.php
      ├── Database/
      │   ├── Migrations/
      │   │   └── xxxx_xx_xx_xxxxxx_create_orders_table.php
      │   └── Factories/
      │       └── OrderFactory.php
      ├── Resources/
      │   └── views/
      │       ├── index.blade.php
      │       ├── create.blade.php
      │       ├── edit.blade.php
      │       └── show.blade.php
      ├── routes.php
      └── OrderServiceProvider.php

```

Example Scenarios
-----------------

[](#example-scenarios)

### 1. Basic CMS Article Module

[](#1-basic-cms-article-module)

```
php artisan make:module Article --fields="title:string,slug:string,content:text,excerpt:text,published_at:timestamp" --views
```

### 2. E-commerce Product Module

[](#2-e-commerce-product-module)

```
php artisan make:module Product --fields="name:string,slug:string,sku:string,price:decimal,cost:decimal,quantity:integer,description:text" --selects="status:draft,published,out_of_stock,discontinued;category:electronics,clothing,home,beauty" --views
```

### 3. User Management Module

[](#3-user-management-module)

```
php artisan make:module User --fields="name:string,email:string:unique,email_verified_at:timestamp,password:string,remember_token:string" --selects="role:admin,editor,member,guest" --type=api
```

### 4. Task Management Module

[](#4-task-management-module)

```
php artisan make:module Task --fields="title:string,description:text,due_date:date,completed_at:timestamp:nullable" --selects="priority:low,medium,high,urgent;status:backlog,todo,in_progress,review,completed" --module-style --views
```

Working with Generated Files
----------------------------

[](#working-with-generated-files)

### Models

[](#models)

The generated models will include fillable fields and constants for select options:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Task extends Model
{
    use HasFactory;

    protected $fillable = ['title', 'description', 'due_date', 'completed_at', 'priority', 'status'];

    // Select options for fields
    public const PRIORITY_OPTIONS = ['low', 'medium', 'high', 'urgent'];
    public const STATUS_OPTIONS = ['backlog', 'todo', 'in_progress', 'review', 'completed'];
}
```

### Controllers

[](#controllers)

The generated controllers include validation for select fields and are prepared to pass options to views:

```
public function create()
{
    // Select options for dropdown fields
    $priorityOptions = Task::PRIORITY_OPTIONS;
    $statusOptions = Task::STATUS_OPTIONS;

    return view('task.create', [
        'priorityOptions' => $priorityOptions,
        'statusOptions' => $statusOptions
    ]);
}

public function store(Request $request)
{
    $validated = $request->validate([
        'title' => 'required|string|max:255',
        'description' => 'nullable|string',
        'due_date' => 'nullable|date',
        'priority' => 'required|in:' . implode(',', Task::PRIORITY_OPTIONS),
        'status' => 'required|in:' . implode(',', Task::STATUS_OPTIONS),
    ]);

    Task::create($validated);

    return redirect()->route('task.index')
        ->with('success', 'Task created successfully.');
}
```

### Views

[](#views)

When using the `--views` option, the package generates view files that include all necessary form fields, including select dropdowns for enum fields:

```

    Status

        Select Status
        @foreach($statusOptions as $option)
            status ?? '') == $option ? 'selected' : '' }}>
                {{ ucfirst(str_replace('_', ' ', $option)) }}

        @endforeach

    @error('status')

            {{ $message }}

    @enderror

```

Configuration
-------------

[](#configuration)

Publish the configuration file:

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

This creates `config/module-generator.php` with options:

```
return [
    'path' => 'App',
    'generate_views' => false,
    'view_path' => 'resources/views',
    'default_type' => 'full',
    'add_routes' => true,
    'api_version' => 'v1',
];
```

The configuration options allow you to:

- `path`: Define the base path for generated files (default: 'App')
- `generate_views`: Automatically generate views for all modules (default: false)
- `view_path`: Define where views will be created (default: 'resources/views')
- `default_type`: Set the default module generation type (default: 'full')
- `add_routes`: Automatically add routes to route files (default: true)
- `api_version`: Define the API version prefix for API routes (default: 'v1')

You can customize these settings according to your project's needs. For example, if you always want to generate views, you could set `generate_views` to `true` in your configuration, eliminating the need to pass the `--views` flag each time.

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

Christopher Vistal

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance45

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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

Every ~0 days

Total

2

Last Release

424d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/848d0a4102e5345827a919b1090b8c0a3f22fa68d3bda67f5e9aa1ea8e46b1d0?d=identicon)[chris06](/maintainers/chris06)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/devkits-module-generator/health.svg)

```
[![Health](https://phpackages.com/badges/devkits-module-generator/health.svg)](https://phpackages.com/packages/devkits-module-generator)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M674](/packages/laravel-socialite)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.1k84.2M225](/packages/laravel-horizon)[laravel/ui

Laravel UI utilities and presets.

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

Tailwind scaffolding for the Laravel framework.

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

Automatic multi-tenancy for your Laravel application.

4.3k6.6M40](/packages/stancl-tenancy)[internachi/modular

Modularize your Laravel apps

1.1k662.4k8](/packages/internachi-modular)

PHPackages © 2026

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