Download the PHP package hexaora/api-crud-generator without Composer
On this page you can find all versions of the php package hexaora/api-crud-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hexaora/api-crud-generator
More information about hexaora/api-crud-generator
Files in hexaora/api-crud-generator
Package api-crud-generator
Short Description A powerful Laravel CRUD generator following Clean Architecture principles with modular structure, API versioning, and comprehensive scaffolding
License MIT
Homepage https://github.com/MahmoudSaeedNST/Hexaora-API-CRUD-Generator
Informations about the package api-crud-generator
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
- 🏗️ 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
- PHP 8.2 or higher
- Laravel 11.0 or 12.0
Installation
You can install the package via Composer:
The package will automatically register the service provider.
Optionally, you can publish the stubs and config file:
Usage
Basic Usage
Generate a complete CRUD for a Product entity in a Catalog module:
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
Generate Everything at Once (New in v1.1.0)
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)
Generates a policy class and auto-registers it in AuthServiceProvider. For Spatie permission integration, enable in config:
With Factory and Seeder (New in v1.1.0)
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
ApiSeederclass
With API Versioning
With Soft Deletes
Without Pagination
Complex Field Types
Available Field Types
| Type | Example | Description |
|---|---|---|
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
unique- Adds unique constraintcascade- For foreign keys, cascade on deletenullOnDelete- For foreign keys, set null on deleterestrict- For foreign keys, restrict on delete
Command Options
| Option | Description | Example |
|---|---|---|
--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
1. Run Migration
2. Bind Repository in Service Provider
Add to your app/Providers/AppServiceProvider.php:
3. Include Routes
Add to your main routes/api.php:
Or for versioned APIs:
4. Seed Test Data (Optional - v1.1.0+)
If you generated factories and seeders, run:
Generated File Structure
Global Files (v1.1.0+)
When using --factory or --seeder, these global files are auto-created and maintained:
Run all seeders with:
API Endpoints
The generated controller provides these endpoints:
| Method | URI | Action | Description |
|---|---|---|---|
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 entity |
For versioned APIs, the URI includes the version: /api/v1/module/entities
Examples
Complete E-commerce Product with Authorization (New in v1.1.0)
This generates everything including policy, factory, and seeder!
Blog System with Testing Data
User Management with Policies
Configuration
Publish the config file to customize behavior:
Available Configuration Options
Intelligent Factory Field Mapping (v1.1.0)
The factory generator intelligently maps fields to appropriate Faker methods:
| Field Pattern | Faker Method | Example |
|---|---|---|
email |
faker->unique()->safeEmail() |
[email protected] |
phone |
faker->phoneNumber() |
(555) 123-4567 |
address |
faker->address() |
123 Main St, City |
url, website |
faker->url() |
https://example.com |
image, photo |
faker->imageUrl() |
https://via.placeholder.com/640x480 |
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
Blog System
User Management
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of api-crud-generator with dependencies
illuminate/support Version ^11.0|^12.0
illuminate/console Version ^11.0|^12.0
illuminate/filesystem Version ^11.0|^12.0