PHPackages                             hexaora/api-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. [HTTP &amp; Networking](/categories/http)
4. /
5. hexaora/api-crud-generator

ActiveLibrary[HTTP &amp; Networking](/categories/http)

hexaora/api-crud-generator
==========================

A powerful Laravel CRUD generator following Clean Architecture principles with modular structure, API versioning, and comprehensive scaffolding

v1.1.0(6mo ago)632MITPHPPHP ^8.2

Since Oct 11Pushed 6mo agoCompare

[ Source](https://github.com/MahmoudSaeedNST/Hexaora-API-CRUD-Generator)[ Packagist](https://packagist.org/packages/hexaora/api-crud-generator)[ Docs](https://github.com/MahmoudSaeedNST/Hexaora-API-CRUD-Generator)[ RSS](/packages/hexaora-api-crud-generator/feed)WikiDiscussions main Synced 1mo ago

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

Hexaora API CRUD Generator
==========================

[](#hexaora-api-crud-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/08a71a79afc190962e81acfb9dc235af77699420f5c7892a004990d6cdcf9270/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686578616f72612f6170692d637275642d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hexaora/api-crud-generator)[![Total Downloads](https://camo.githubusercontent.com/1b536b423b7b54e9a077a84dd22950c4f38d41c9a014fd756353cbd4acd12784/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f686578616f72612f6170692d637275642d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hexaora/api-crud-generator)[![License](https://camo.githubusercontent.com/4c85c51b703471e44fe0bec05e5a02f39ea68c587227b9d1ba2a43771dd6b7f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f686578616f72612f6170692d637275642d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hexaora/api-crud-generator)

A Laravel CRUD generator that follows Clean Architecture principles with modular structure, API versioning, and comprehensive scaffolding. Generate complete CRUD operations with controllers, services, repositories, models, requests, resources, migrations, and routes in seconds.

Features
--------

[](#features)

- 🏗️ **Clean Architecture**: Follows Domain-Driven Design principles
- 📦 **Modular Structure**: Organizes code into logical modules
- 🚀 **API Versioning**: Built-in support for API versioning
- 🔄 **Repository Pattern**: Includes repository interfaces and implementations
- ✅ **Request Validation**: Generates form request classes with validation rules
- 📄 **API Resources**: Creates Eloquent API resource classes
- 🗄️ **Migration Support**: Generates database migrations with field definitions
- 🛣️ **Route Generation**: Creates route files with proper namespacing
- � **Policy Generation**: Auto-generates authorization policies (with optional Spatie support)
- 🏭 **Factory Generation**: Creates smart model factories with intelligent faker mapping
- 🌱 **Seeder Generation**: Generates database seeders with global linking
- �🔧 **Configurable**: Support for soft deletes, pagination, field types, and more
- 📚 **Comprehensive**: Generates 10+ files per entity in proper structure

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 11.0 or 12.0

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

[](#installation)

You can install the package via Composer:

```
composer require hexaora/api-crud-generator
```

The package will automatically register the service provider.

Optionally, you can publish the stubs and config file:

```
# Publish stubs
php artisan vendor:publish --tag="hexaora-stubs"

# Publish config
php artisan vendor:publish --tag="hexaora-config"
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Generate a complete CRUD for a `Product` entity in a `Catalog` module:

```
php artisan make:hexaora Product --module=Catalog --fields="name:string,price:decimal:10,2,description:text"
```

This will generate:

- Model (`app/Modules/Catalog/Domain/Models/Product.php`)
- Repository Interface (`app/Modules/Catalog/Domain/Repositories/ProductRepositoryInterface.php`)
- Repository Implementation (`app/Modules/Catalog/Infrastructure/Repositories/ProductRepository.php`)
- Service Class (`app/Modules/Catalog/Application/Services/ProductService.php`)
- API Resource (`app/Modules/Catalog/Infrastructure/Resources/ProductResource.php`)
- Store Request (`app/Modules/Catalog/Application/Requests/ProductStoreRequest.php`)
- Update Request (`app/Modules/Catalog/Application/Requests/ProductUpdateRequest.php`)
- Controller (`app/Modules/Catalog/Presentation/Controllers/ProductController.php`)
- Migration (`database/migrations/xxxx_create_products_table.php`)
- Routes (`app/Modules/Catalog/routes/api.php`)

### Advanced Usage

[](#advanced-usage)

#### Generate Everything at Once (New in v1.1.0)

[](#generate-everything-at-once-new-in-v110)

```
php artisan make:hexaora Product --module=Inventory --fields="name:string,price:decimal:10,2" --all
```

The `--all` flag generates:

- All core CRUD files (model, controller, service, repository, etc.)
- Policy class with authorization logic
- Factory with intelligent faker field mapping
- Seeder for testing data
- Permission seeder (if Spatie mode is enabled)

#### With Policy Authorization (New in v1.1.0)

[](#with-policy-authorization-new-in-v110)

```
php artisan make:hexaora Product --module=Catalog --fields="name:string,price:decimal:10,2" --policy
```

Generates a policy class and auto-registers it in `AuthServiceProvider`. For Spatie permission integration, enable in config:

```
// config/hexaora.php
'policies' => [
    'spatie' => true,  // Enable Spatie permissions
],
```

#### With Factory and Seeder (New in v1.1.0)

[](#with-factory-and-seeder-new-in-v110)

```
php artisan make:hexaora Product --module=Inventory --fields="name:string,sku:string:unique,price:decimal:10,2,description:text" --factory --seeder
```

This generates:

- Smart factory with intelligent faker methods based on field types and names
- Seeder that uses the factory
- Global linker files (`database/api_factories.php`, `database/api_seeders.php`)
- Master `ApiSeeder` class

#### With API Versioning

[](#with-api-versioning)

```
php artisan make:hexaora User --module=Auth --api-version=v1 --fields="name:string,email:string:unique,password:string"
```

#### With Soft Deletes

[](#with-soft-deletes)

```
php artisan make:hexaora Post --module=Blog --softdeletes --fields="title:string,content:text,published_at:timestamp"
```

#### Without Pagination

[](#without-pagination)

```
php artisan make:hexaora Category --module=Blog --no-pagination --fields="name:string:unique,slug:string:unique"
```

#### Complex Field Types

[](#complex-field-types)

```
php artisan make:hexaora Order --module=Sales --fields="customer_id:foreignId:cascade,total:decimal:10,2,status:string,notes:text,shipped_at:timestamp"
```

### Available Field Types

[](#available-field-types)

TypeExampleDescription`string``name:string`VARCHAR(255)`text``description:text`TEXT`integer``quantity:integer`INTEGER`boolean``is_active:boolean`BOOLEAN`decimal``price:decimal:10,2`DECIMAL(10,2)`timestamp``published_at:timestamp`TIMESTAMP`date``birth_date:date`DATE`foreignId``user_id:foreignId:cascade`Foreign key with constraint### Field Modifiers

[](#field-modifiers)

- `unique` - Adds unique constraint
- `cascade` - For foreign keys, cascade on delete
- `nullOnDelete` - For foreign keys, set null on delete
- `restrict` - For foreign keys, restrict on delete

### Command Options

[](#command-options)

OptionDescriptionExample`--module`Module name (required)`--module=Blog``--fields`Comma-separated field definitions`--fields="name:string,email:string"``--api-version`API version`--api-version=v1``--no-pagination`Disable pagination`--no-pagination``--softdeletes`Add soft deletes`--softdeletes``--policy`Generate policy class ⭐ New`--policy``--factory`Generate factory class ⭐ New`--factory``--seeder`Generate seeder class ⭐ New`--seeder``--all`Generate everything (policy, factory, seeder) ⭐ New`--all``--force`Overwrite existing files`--force`Post-Generation Setup
---------------------

[](#post-generation-setup)

### 1. Run Migration

[](#1-run-migration)

```
php artisan migrate
```

### 2. Bind Repository in Service Provider

[](#2-bind-repository-in-service-provider)

Add to your `app/Providers/AppServiceProvider.php`:

```
public function register()
{
    $this->app->bind(
        \App\Modules\YourModule\Domain\Repositories\YourEntityRepositoryInterface::class,
        \App\Modules\YourModule\Infrastructure\Repositories\YourEntityRepository::class
    );
}
```

### 3. Include Routes

[](#3-include-routes)

Add to your main `routes/api.php`:

```
// Include module routes
require app_path('Modules/YourModule/routes/api.php');
```

Or for versioned APIs:

```
// Include versioned module routes
require app_path('Modules/YourModule/routes/api_v1.php');
```

### 4. Seed Test Data (Optional - v1.1.0+)

[](#4-seed-test-data-optional---v110)

If you generated factories and seeders, run:

```
# Seed all API module data at once
php artisan db:seed --class=ApiSeeder

# Or seed specific module
php artisan db:seed --class=\\App\\Modules\\YourModule\\Database\\Seeders\\YourEntitySeeder
```

Generated File Structure
------------------------

[](#generated-file-structure)

```
app/Modules/YourModule/
├── Application/
│   ├── Services/
│   │   └── EntityService.php
│   └── Requests/
│       ├── EntityStoreRequest.php
│       └── EntityUpdateRequest.php
├── Domain/
│   ├── Models/
│   │   └── Entity.php
│   ├── Repositories/
│   │   └── EntityRepositoryInterface.php
│   └── Policies/                        ⭐ New (with --policy or --all)
│       └── EntityPolicy.php
├── Database/                             ⭐ New (with --factory or --seeder)
│   ├── factories/
│   │   └── EntityFactory.php
│   └── seeders/
│       ├── EntitySeeder.php
│       └── EntityPermissionSeeder.php    (if Spatie mode enabled)
├── Infrastructure/
│   ├── Repositories/
│   │   └── EntityRepository.php
│   └── Resources/
│       └── EntityResource.php
├── Presentation/
│   └── Controllers/
│       └── EntityController.php (or V1/Controllers/ for versioned)
└── routes/
    └── api.php (or api_v1.php for versioned)

```

### Global Files (v1.1.0+)

[](#global-files-v110)

When using `--factory` or `--seeder`, these global files are auto-created and maintained:

```
database/
├── api_factories.php          # Links all module factories
├── api_seeders.php            # Registry of all module seeders
└── seeders/
    └── ApiSeeder.php          # Master seeder to run all module seeders

```

Run all seeders with:

```
php artisan db:seed --class=ApiSeeder
```

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

[](#api-endpoints)

The generated controller provides these endpoints:

MethodURIActionDescription`GET``/api/module/entities``index`List all entities`POST``/api/module/entities``store`Create new entity`GET``/api/module/entities/{id}``show`Show specific entity`PUT/PATCH``/api/module/entities/{id}``update`Update entity`DELETE``/api/module/entities/{id}``destroy`Delete entityFor versioned APIs, the URI includes the version: `/api/v1/module/entities`

Examples
--------

[](#examples)

### Complete E-commerce Product with Authorization (New in v1.1.0)

[](#complete-e-commerce-product-with-authorization-new-in-v110)

```
php artisan make:hexaora Product \
    --module=Catalog \
    --fields="name:string,sku:string:unique,price:decimal:10,2,cost:decimal:10,2,description:text,category_id:foreignId:cascade,is_active:boolean" \
    --all
```

This generates everything including policy, factory, and seeder!

### Blog System with Testing Data

[](#blog-system-with-testing-data)

```
php artisan make:hexaora Post \
    --module=Blog \
    --softdeletes \
    --fields="title:string,slug:string:unique,content:text,excerpt:text,author_id:foreignId:cascade,published_at:timestamp,is_featured:boolean" \
    --factory \
    --seeder
```

### User Management with Policies

[](#user-management-with-policies)

```
php artisan make:hexaora User \
    --module=Auth \
    --api-version=v1 \
    --fields="name:string,email:string:unique,email_verified_at:timestamp,password:string" \
    --policy
```

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

[](#configuration)

Publish the config file to customize behavior:

```
php artisan vendor:publish --tag="hexaora-config"
```

### Available Configuration Options

[](#available-configuration-options)

```
// config/hexaora.php

return [
    'module_namespace' => 'App\\Modules',

    'pagination' => [
        'per_page' => 15,
    ],

    'policies' => [
        'spatie' => false,           // Enable Spatie permission integration
        'namespace' => 'App\\Modules\\{module}\\Domain\\Policies',
        'auto_register' => true,     // Auto-register in AuthServiceProvider
    ],

    'factories' => [
        'count' => 10,               // Default factory count in seeders
        'namespace' => 'App\\Modules\\{module}\\Database\\Factories',
    ],

    'seeders' => [
        'namespace' => 'App\\Modules\\{module}\\Database\\Seeders',
    ],
];
```

### Intelligent Factory Field Mapping (v1.1.0)

[](#intelligent-factory-field-mapping-v110)

The factory generator intelligently maps fields to appropriate Faker methods:

Field PatternFaker MethodExample`email``faker->unique()->safeEmail()``phone``faker->phoneNumber()`(555) 123-4567`address``faker->address()`123 Main St, City`url`, `website``faker->url()``image`, `photo``faker->imageUrl()``title`, `name``faker->words(3, true)`Lorem Ipsum Dolor`description`, `content``faker->paragraph()`Long text...`decimal`, `price``faker->randomFloat(2, 10, 1000)`523.45`boolean``faker->boolean()`true/false`date``faker->date()`2024-01-15`foreignId``RelatedModel::factory()`Auto-creates relation### E-commerce Product Management

[](#e-commerce-product-management)

```
php artisan make:hexaora Product --module=Catalog --fields="name:string,sku:string:unique,price:decimal:10,2,cost:decimal:10,2,description:text,category_id:foreignId:cascade,is_active:boolean"
```

### Blog System

[](#blog-system)

```
php artisan make:hexaora Post --module=Blog --softdeletes --fields="title:string,slug:string:unique,content:text,excerpt:text,author_id:foreignId:cascade,published_at:timestamp,is_featured:boolean"
```

### User Management

[](#user-management)

```
php artisan make:hexaora User --module=Auth --api-version=v1 --fields="name:string,email:string:unique,email_verified_at:timestamp,password:string,remember_token:string"
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Mahmoud Saeed](https://github.com/MahmoudSaeedNST)

License
-------

[](#license)

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

###  Health Score

36

—

LowBetter than 81% of packages

Maintenance70

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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 ~6 days

Total

2

Last Release

203d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6dbcb5845034cf1fbd72126ca3f6bd6b13aab0d501b86d09f4666f79c0622134?d=identicon)[Hexaora](/maintainers/Hexaora)

---

Top Contributors

[![MahmoudSaeedNST](https://avatars.githubusercontent.com/u/63323010?v=4)](https://github.com/MahmoudSaeedNST "MahmoudSaeedNST (5 commits)")

---

Tags

apilaravelrestscaffoldinggeneratorartisancrudrepository patternmodularclean architecture

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[api-platform/laravel

API Platform support for Laravel

59126.4k5](/packages/api-platform-laravel)[sdv/laravel-endpoint

Laravel Endpoint is a CRUD REST API package for Laravel.

1118.8k](/packages/sdv-laravel-endpoint)[bjerke/laravel-bread

A boilerplate package for BREAD operations through REST API in Laravel

115.2k](/packages/bjerke-laravel-bread)

PHPackages © 2026

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