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

ActiveLibrary[Framework](/categories/framework)

rayhan2001/module-generator
===========================

Laravel CRUD Module Generator (API + Web)

v0.0.1(7mo ago)01MITPHPPHP ^8.0

Since Oct 1Pushed 7mo agoCompare

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

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

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

[](#laravel-crud-module-generator)

[![Laravel](https://camo.githubusercontent.com/b41f9b916485b5a076b4174be55450105ae0ec45a5daa0b7417d85559ca71d8d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d392e7825323025374325323031302e7825323025374325323031312e7825323025374325323031322e782d7265642e737667)](https://laravel.com)[![PHP](https://camo.githubusercontent.com/d4b5fa4adf514144779a7864904c5e15236c0e798635240c7f6ce9a455657b80/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532422d626c75652e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Packagist](https://camo.githubusercontent.com/ff2dca60242ef0d1b599e03a15405dd593833a5b4259addc1d1f8864655d3a4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72617968616e323030312f6d6f64756c652d67656e657261746f722e737667)](https://packagist.org/packages/rayhan2001/module-generator)

A **powerful Laravel CRUD module generator** that quickly scaffolds fully functional modules for both **Web (Blade)** and **API** applications. Generate complete CRUD operations with **Model, Repository, Controller, Request, Migration, Routes, and Views** in seconds.

This package is **developer-friendly**, supports **direct repository injection** in controllers, and provides **configurable default type** (web/api).

---

✨ Features
----------

[](#-features)

- 🚀 **Complete CRUD Generation**: Model, Repository, Controller, Request, Migration
- 🌐 **Dual Module Types**: Web (Blade) and API modules
- 💉 **Direct Repository Injection**: No interfaces needed
- 🛣️ **Auto Route Generation**: Clean group-controller format
- 🎨 **Blade Views**: Auto-generated views for web modules
- ⚙️ **Configurable Defaults**: Set default module type on installation
- 🔄 **Force Overwrite**: Overwrite existing files with `--force` flag
- 📱 **Laravel 9-12 Support**: Compatible with latest Laravel versions

---

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

[](#-installation)

### Method 1: Via Packagist (Recommended)

[](#method-1-via-packagist-recommended)

```
composer require rayhan2001/module-generator
```

### Method 2: Via GitHub (Development)

[](#method-2-via-github-development)

Add the package repository to your `composer.json`:

```
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/rayhan2001/module-generator"
    }
]
```

Then install:

```
composer require rayhan2001/module-generator:dev-main
```

### Method 3: Local Development

[](#method-3-local-development)

For local development, you can use a path repository:

```
# In your Laravel project
composer config repositories.local path /path/to/module-generator
composer require rayhan2001/module-generator:@dev
```

---

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

[](#️-configuration)

After installation, run the setup command:

```
php artisan module:install
```

This will:

- Ask for your preferred default module type (`api` or `web`)
- Publish the configuration file to `config/module-generator.php`
- Set up the package for use

**Example output:**

```
⚙️  Module Generator installation

 Default module type? [api]:
  [0] api
  [1] web
 > Config published to config/module-generator.php and default type set to: api
✅ Installation complete. You can now run: php artisan make:module Name --type=web|api

```

---

🚀 Usage
-------

[](#-usage)

### Generate a new module

[](#generate-a-new-module)

```
# Use default type from config (api/web)
php artisan make:module Category

# Override type explicitly
php artisan make:module Product --type=web
php artisan make:module Tag --type=api

# Force overwrite existing files
php artisan make:module Category --force
```

### Available Commands

[](#available-commands)

```
# List all available commands
php artisan list | grep module

# Output:
# make:module               Generate a full CRUD module with Controller, Repository, Requests, Views, Migration & Routes
# module:install            Install and configure Rayhan2001 Module Generator package
```

---

📁 Generated Files Structure
---------------------------

[](#-generated-files-structure)

For a `Category` module, the following files will be generated:

```
app/
├── Models/Category.php
├── Repositories/CategoryRepository.php
├── Http/Controllers/CategoryController.php
└── Http/Requests/
    ├── CategoryRequest.php
    └── UpdateCategoryRequest.php

database/migrations/
└── YYYY_MM_DD_HHMMSS_create_categories_table.php

routes/
└── web.php OR api.php (routes appended)

resources/views/categories/ (only for web type)
├── index.blade.php
├── create.blade.php
├── edit.blade.php
└── form.blade.php

```

---

🛣️ Generated Routes
-------------------

[](#️-generated-routes)

### Web Module Routes

[](#web-module-routes)

```
// Module: Category
use App\Http\Controllers\CategoryController;

Route::controller(CategoryController::class)
    ->prefix('categories')
    ->as('categories.')
    ->group(function () {
        Route::get('/', 'index')->name('index');
        Route::get('/create', 'create')->name('create');
        Route::post('/store', 'store')->name('store');
        Route::get('/edit/{id}', 'edit')->name('edit');
        Route::put('/update/{id}', 'update')->name('update');
        Route::delete('/delete/{id}', 'destroy')->name('destroy');
    });
```

### API Module Routes

[](#api-module-routes)

```
// Module: Category
use App\Http\Controllers\CategoryController;

Route::controller(CategoryController::class)
    ->prefix('categories')
    ->as('categories.')
    ->group(function () {
        Route::get('/', 'index')->name('index');
        Route::post('/store', 'store')->name('store');
        Route::get('/{id}', 'show')->name('show');
        Route::put('/update/{id}', 'update')->name('update');
        Route::delete('/delete/{id}', 'destroy')->name('destroy');
    });
```

---

🎯 Example Usage
---------------

[](#-example-usage)

### 1. Generate an API Module

[](#1-generate-an-api-module)

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

**Generated Controller:**

```
