PHPackages                             rahulp/crud-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. rahulp/crud-generator

ActiveLibrary[Framework](/categories/framework)

rahulp/crud-generator
=====================

A Laravel package for generating CRUD operations with Repository Pattern

v1.0.3(1y ago)04MITPHPPHP ^8.2

Since Jan 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rahulpathak1706/package-rahulp)[ Packagist](https://packagist.org/packages/rahulp/crud-generator)[ RSS](/packages/rahulp-crud-generator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (5)Used By (0)

Laravel CRUD Generator with Repository Pattern
==============================================

[](#laravel-crud-generator-with-repository-pattern)

[![Latest Version on Packagist](https://camo.githubusercontent.com/91892b1ed3d503bebdc9df1c95fd9ff03d718b8095f301bbc85d87084fb8a50a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726168756c702f637275642d67656e657261746f722e737667)](https://packagist.org/packages/rahulp/crud-generator)[![License](https://camo.githubusercontent.com/59162da2a764b017f66dbd99af660f9d3421b260b8cc0a909c57b0a7a9d65b96/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726168756c702f637275642d67656e657261746f722e737667)](https://github.com/rahulpathak1706/package-rahulp/blob/main/LICENSE)

A powerful Laravel package that generates complete CRUD operations with Repository Pattern implementation, along with API response helpers and database transaction middleware.

Features
--------

[](#features)

- 🚀 Project setup with essential middleware and helpers
- 🏗️ Generates Models, Controllers, Services, and Repositories
- 📦 Automatic repository binding setup
- 🔄 Database transaction middleware
- 📬 API response helper functions
- ⚡ Support for Laravel 11
- 🛠️ Customizable validation rules

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

[](#installation)

You can install the package via composer:

```
composer require rahulp/crud-generator
```

Commands
--------

[](#commands)

### 1. Project Setup (Required First)

[](#1-project-setup-required-first)

```
php artisan project:setup
```

This command sets up essential components needed for the CRUD operations:

#### A. Database Transaction Middleware

[](#a-database-transaction-middleware)

Automatically adds and registers middleware that:

- Wraps all API requests in database transactions
- Automatically commits on successful responses
- Rolls back on exceptions or error responses (4xx, 5xx)
- Handles exceptions gracefully

#### B. API Response Helpers

[](#b-api-response-helpers)

Adds global helper functions for consistent API responses:

1. Success Response Helper:

```
ok($message = null, $data = [], $status = 200);

// Examples:
return ok('User profile fetched', $user);
return ok('Post created', $post, 201);
```

Success Response Format:

```
{
    "meta": {
        "status": 200,
        "message": "User profile fetched",
        "success": true
    },
    "data": {
        "id": 1,
        "name": "John Doe",
        "email": "john@example.com"
    }
}
```

2. Error Response Helper:

```
error($message = null, $data = [], $type = null);

// Examples:
return error('Validation failed', $validator->errors(), 'validation');
return error('Post not found', [], 'notfound');
return error('Unauthorized access', [], 'forbidden');
```

Error Types and Status Codes:

- `validation` (422) - Validation errors
- `unauthenticated` (401) - Authentication required
- `notfound` (404) - Resource not found
- `forbidden` (403) - Permission denied
- `processError` (400) - Bad request
- `loginCase` (306) - Login specific errors
- Default (500) - Server errors

Error Response Format:

```
{
    "meta": {
        "status": 422,
        "message": "Validation failed",
        "success": false
    },
    "data": {
        "email": ["The email field is required"],
        "name": ["The name field is required"]
    }
}
```

### 2. Generate CRUD Operations

[](#2-generate-crud-operations)

After setting up the project, you can generate CRUD operations:

```
php artisan make:crud {model} {columns}
```

Parameters:

- `model`: Name of the model (e.g., Post, User, Product)
- `columns`: Column definitions in format: name:type:required|nullable:default

Supported Column Types:

- `string` - String/varchar fields
- `integer` - Whole numbers
- `decimal` - Decimal numbers (prices, measurements)
- `text` - Long text content
- `boolean` - True/false values
- `date` - Date only
- `datetime` - Date and time
- `timestamp` - Timestamps

Examples:

1. Basic Post Model:

```
php artisan make:crud Post title:string:required content:text:nullable
```

2. Product with Default Values:

```
php artisan make:crud Product \
    name:string:required \
    price:decimal:required:0.00 \
    description:text:nullable \
    stock:integer:required:0 \
    is_active:boolean:required:true
```

3. User Model with Validation:

```
php artisan make:crud User \
    name:string:required \
    email:string:required:unique \
    phone:string:nullable \
    status:string:required:active
```

Each `make:crud` command generates:

1. Database migration
2. Model with fillable fields and defaults
3. Repository interface and implementation
4. Service class for business logic
5. API controller with validation
6. Automatic repository binding

Generated Structure
-------------------

[](#generated-structure)

For a Post model, it creates:

```
app/
├── Http/
│   ├── Controllers/
│   │   └── PostController.php
│   └── Middleware/
│       └── DBTransaction.php
├── Models/
│   └── Post.php
├── Repositories/
│   ├── Interfaces/
│   │   └── PostRepositoryInterface.php
│   └── PostRepository.php
├── Services/
│   └── PostService.php
└── Helpers/
    └── functions.php

```

API Endpoints
-------------

[](#api-endpoints)

Each CRUD generation creates these endpoints:

```
# List all records with pagination
GET /api/posts

# Create new record
POST /api/posts

# Get single record
GET /api/posts/{id}

# Update record
PUT /api/posts/{id}

# Delete record
DELETE /api/posts/{id}
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

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

Credits
-------

[](#credits)

- [Rahul Pathak](https://github.com/rahulpathak1706/package-rahulp)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Every ~0 days

Total

4

Last Release

531d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76512519?v=4)[rahulpathak1706](/maintainers/rahulpathak1706)[@rahulpathak1706](https://github.com/rahulpathak1706)

---

Top Contributors

[![rahulp-webmob](https://avatars.githubusercontent.com/u/184219281?v=4)](https://github.com/rahulp-webmob "rahulp-webmob (6 commits)")

### Embed Badge

![Health badge](/badges/rahulp-crud-generator/health.svg)

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

###  Alternatives

[laravel/octane

Supercharge your Laravel application's performance.

4.0k26.6M223](/packages/laravel-octane)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[code16/sharp

Laravel Content Management Framework

79164.7k8](/packages/code16-sharp)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3891.8k](/packages/codewithdennis-larament)[r2luna/brain

Brain: A process-driven architecture alternative for your Laravel Application.

6338.7k1](/packages/r2luna-brain)

PHPackages © 2026

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