PHPackages                             zaidysf/zcrudgen - 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. [API Development](/categories/api)
4. /
5. zaidysf/zcrudgen

ActiveLibrary[API Development](/categories/api)

zaidysf/zcrudgen
================

Laravel CRUD API Generator with advanced features

v1.0.4(1y ago)18[4 PRs](https://github.com/zaidysf/zcrudgen/pulls)MITPHPPHP ^8.2CI passing

Since Dec 21Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/zaidysf/zcrudgen)[ Packagist](https://packagist.org/packages/zaidysf/zcrudgen)[ Docs](https://github.com/zaidysf/zcrudgen)[ GitHub Sponsors]()[ RSS](/packages/zaidysf-zcrudgen/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (12)Versions (11)Used By (0)

ZCrudGen - Laravel CRUD API Generator
=====================================

[](#zcrudgen---laravel-crud-api-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c1ffbab4b410d9b2e28715121e3806b26ba5016d9d8fd2940f3bb71551e5bc54/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a6169647973662f7a6372756467656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zaidysf/zcrudgen)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7edb03cbe02f7d0fe8d1f251f1c7278173581c48f06bd2b5cfce927ff1927ca4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a6169647973662f7a6372756467656e2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/zaidysf/zcrudgen/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/f073da879a505e0dc4910bdc3b5cde4fe3042a914f53800e88e05c23f0819232/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a6169647973662f7a6372756467656e2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/zaidysf/zcrudgen/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/eb98434aedd3cd8ddbfd183b67c0564bbc12125cb87258f995a3e9892b0f50d2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a6169647973662f7a6372756467656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zaidysf/zcrudgen)[![License](https://camo.githubusercontent.com/a0d8f031d6013a75924be34a430841273debef976c2758411b5e3fdce73cf786/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a6169647973662f7a6372756467656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zaidysf/zcrudgen)[![PHP Version](https://camo.githubusercontent.com/8471ef1fdfd9d18a4ae4326872b83cb06624d1ee9fe0b9b271ef55a500bb1f6f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7a6169647973662f7a6372756467656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zaidysf/zcrudgen)[![Laravel Version](https://camo.githubusercontent.com/b27752400043b624b6d24cdcd84d821e89fd1b1da48ae8164464aee309866c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302e7825374331312e782d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zaidysf/zcrudgen)[![Static Analysis](https://camo.githubusercontent.com/13eedf0640b6b8d8704144623bb998329dd9c5414f6a999c3542485d05cf2582/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a6169647973662f7a6372756467656e2f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/zaidysf/zcrudgen/actions?query=workflow%3Aphpstan+branch%3Amain)[![GitHub Release Date](https://camo.githubusercontent.com/1dcabd1aea42be446da58e1af816f4d9088d9c8aad5e855c9f7b544f4b69fbf5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f7a6169647973662f7a6372756467656e3f7374796c653d666c61742d737175617265)](https://github.com/zaidysf/zcrudgen/releases)

A sophisticated Laravel package that automates the creation of production-ready CRUD APIs. Built with modern Laravel practices in mind, ZCrudGen generates fully functional REST APIs following the Service Repository pattern, complete with advanced features like intelligent filtering, OpenAPI documentation, and AI-powered business logic.

🚀 Key Features
--------------

[](#-key-features)

- **Complete CRUD Operations**: Generates index, show, create, update, and delete endpoints
- **Service Repository Pattern**: Follows best practices with proper separation of concerns
- **Smart Schema Detection**: Automatically analyzes your database structure
- **Advanced Filtering**: Filter by any field with support for complex queries
- **Relationship Handling**: Supports multiple related models (e.g., country -&gt; province -&gt; city)
- **API Documentation**: Automatic OpenAPI/Swagger documentation generation
- **Authentication &amp; Authorization**: Built-in middleware and permission integration
- **AI-Powered Logic**: Optional AI assistance for generating business logic (powered by OpenAI)
- **Highly Customizable**: All generated code is placed in your project for full control
- **Modern PHP**: Built for PHP 8.2+ with proper type hinting and nullability
- **Well-Tested**: Comprehensive test suite ensuring reliability

💡 Perfect For
-------------

[](#-perfect-for)

- Rapid API development
- Projects requiring standardized CRUD operations
- Teams looking to maintain consistent code structure
- Applications needing well-documented APIs
- Developers who value clean, maintainable code

🛠️ Built With
-------------

[](#️-built-with)

- Modern PHP 8.2+
- Laravel 10/11 Support
- Service Repository Pattern
- OpenAPI/Swagger Documentation
- AI Integration Capabilities

⭐ Why ZCrudGen?
---------------

[](#-why-zcrudgen)

- **Save Time**: Eliminate repetitive CRUD boilerplate code
- **Best Practices**: Generated code follows Laravel and PHP best practices
- **Maintainable**: Clean, well-documented, and easily modifiable code
- **Future-Proof**: Built with modern PHP features and practices
- **Flexible**: Works with existing projects and can be customized to your needs

ZCrudGen Documentation
======================

[](#zcrudgen-documentation)

Table of Contents
-----------------

[](#table-of-contents)

1. [Requirements](#requirements)
2. [Dependencies](#dependencies)
3. [Installation](#installation)
4. [Configuration](#configuration)
5. [Basic Usage](#basic-usage)
6. [Advanced Features](#advanced-features)
7. [AI Integration](#ai-integration)
8. [OpenAPI/Swagger](#openapi-swagger)
9. [Testing](#testing)
10. [Contributing](#contributing)

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 10.x or 11.x
- Scramble for Laravel (`composer require dedoc/scramble`)

Dependencies
------------

[](#dependencies)

This package relies on the following packages:

- spatie/laravel-package-tools
- doctrine/dbal
- dedoc/scramble (for API documentation)

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

[](#installation)

Install the package via composer:

```
composer require zaidysf/zcrudgen
php artisan vendor:publish --provider="ZaidYasyaf\Zcrudgen\ZcrudgenServiceProvider"
```

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

[](#configuration)

The package can be configured through the config/zcrudgen.php file. Key options include:

- Namespace customization
- Path configuration
- Authentication &amp; authorization settings
- OpenAPI/Swagger configuration
- AI integration settings

Example Configuration

```
return [
    'namespace' => 'App',
    'paths' => [
        'model' => app_path('Models'),
        'controller' => app_path('Http/Controllers/API'),
        // ...
    ],
    'auth' => [
        'middleware' => [
            'enabled' => true,
            'default' => ['auth:sanctum'],
        ],
        'permissions' => [
            'enabled' => true,
            'prefix' => ['create', 'read', 'update', 'delete'],
        ],
    ],
    'swagger' => [
        'enabled' => true,
        'version' => '3.0.0',
    ],
    'ai' => [
        'enabled' => false,
        'api_key' => env('OPENAI_API_KEY'),
        'model' => 'gpt-4',
    ],
];
```

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

[](#basic-usage)

Generate a basic CRUD API:

```
php artisan zcrudgen:make User
```

With relationships:

```
php artisan zcrudgen:make City --relations="country,state"
```

With middleware:

```
php artisan zcrudgen:make Product --middleware="auth:sanctum,verified"
```

With permissions:

```
php artisan zcrudgen:make Order --permissions
```

Advanced Features
-----------------

[](#advanced-features)

### Relationships

[](#relationships)

The package supports automatic generation of related models and their relationships:

```
php artisan zcrudgen:make City --relations="country,state"
```

This will:

- Set up proper model relationships
- Include related data in resources
- Add relationship validation in requests
- Generate nested API documentation

### Custom Middleware

[](#custom-middleware)

You can specify custom middleware for your API endpoints:

```
php artisan zcrudgen:make Product --middleware="auth:sanctum,verified,custom"
```

### Permission Integration

[](#permission-integration)

When using the --permissions flag, the package will:

- Generate standard CRUD permissions (create-{model}, read-{model}, etc.)
- Add permission middleware to controllers
- Document permission requirements in OpenAPI

### Advanced Filtering

[](#advanced-filtering)

All generated APIs support advanced filtering:

```
// Filter by exact match
/api/users?name=John

// Filter by date range
/api/users?created_at[from]=2024-01-01&created_at[to]=2024-12-31

// Filter by relationship
/api/cities?country_id=1

// Multiple filters
/api/users?status=active&role=admin
```

AI Integration
--------------

[](#ai-integration)

### Configuration

[](#configuration-1)

Enable AI integration in your .env:

```
ZCRUDGEN_AI_ENABLED=true
OPENAI_API_KEY=your-api-key
```

### Features

[](#features)

The AI integration provides:

- Intelligent business logic generation
- Smart validation rules
- Automated event handling
- Cache strategy suggestions
- Data transformation optimization

### Example AI-Generated Logic

[](#example-ai-generated-logic)

```
public function create(array $data): Model
{
    // AI-generated validation
    $this->validateCreationRules($data);

    // AI-suggested caching strategy
    $cacheKey = "product:{$data['sku']}";

    if (Cache::has($cacheKey)) {
        throw new DuplicateProductException();
    }

    DB::beginTransaction();
    try {
        $product = $this->repository->create($data);

        // AI-suggested event
        ProductCreated::dispatch($product);

        Cache::put($cacheKey, $product, now()->addDay());

        DB::commit();
        return $product;
    } catch (\Exception $e) {
        DB::rollBack();
        throw $e;
    }
}
```

OpenAPI/Swagger
---------------

[](#openapiswagger)

### Automatic Documentation

[](#automatic-documentation)

The package automatically generates OpenAPI documentation for all endpoints:

```
/api/products:
  get:
    tags:
      - Products
    summary: List all products
    parameters:
      - name: name
        in: query
        schema:
          type: string
      # ... other parameters
```

### Customization

[](#customization)

You can customize the generated documentation in `config/zcrudgen.php`:

```
'swagger' => [
    'enabled' => true,
    'version' => '3.0.0',
    'title' => 'Your API Title',
    'description' => 'Your API Description',
],
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run specific tests:

```
composer test -- --filter=TestName
```

Coverage report:

```
composer test-coverage
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance69

Regular maintenance activity

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.1% 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

5

Last Release

505d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aae870c91cef6ca988288dd97c7459a0721278f7ed2aac346a66305cbe88f2e9?d=identicon)[zaidysf](/maintainers/zaidysf)

---

Top Contributors

[![zaidysf](https://avatars.githubusercontent.com/u/5093672?v=4)](https://github.com/zaidysf "zaidysf (52 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laravelZaid Yasyafzcrudgen

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/zaidysf-zcrudgen/health.svg)

```
[![Health](https://phpackages.com/badges/zaidysf-zcrudgen/health.svg)](https://phpackages.com/packages/zaidysf-zcrudgen)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.0k7.8M57](/packages/dedoc-scramble)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

208.8k](/packages/njoguamos-laravel-plausible)

PHPackages © 2026

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