Download the PHP package mehedi8gb/api-crudify without Composer
On this page you can find all versions of the php package mehedi8gb/api-crudify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mehedi8gb/api-crudify
More information about mehedi8gb/api-crudify
Files in mehedi8gb/api-crudify
Package api-crudify
Short Description Automate CRUD operations for Laravel APIs.
License MIT
Homepage https://github.com/mehedi8gb/api-crudify
Informations about the package api-crudify
Api Crudify
Laravel API Engine for Scalable Query-Driven Applications
Api Crudify is a professional-grade Laravel package that automates generation of robust, scalable, and standardized API CRUD components. It enforces the Service-Repository design pattern and implements a Chain of Responsibility pipeline for complex API queries — filtering, sorting, relation loading, soft deletes, and pagination — all driven by query parameters.
🚀 Key Features
- Standardized Architecture — Generates Controller, Service, Repository, Model, FormRequests, Resource, Migration, Factory, Seeder, and Feature Test in one command.
- Chain of Responsibility Query Pipeline — Modular, ordered handlers process every API request: SoftDelete → Relations → Filter → Sort → Pagination.
- Advanced Dynamic Filtering — Frontend-friendly
?q=shorthand plus low-level?where=and?orWhere=with relation traversal support. - Smart Relation Loading — Respects explicitly passed relations, model
$with, or Eloquent eager loads automatically. - Soft Delete Awareness —
?trashed=withor?trashed=onlyquery params built in. - Domain-Driven Design Ready — Full support for nested namespaces:
V1/Inventory/Product. - Auto-Restoration — Detects and restores any missing base classes on every
crudify:makerun. - Route Management — Automatically registers API routes and
usestatements. - Helper Utilities — Global helper functions for responses, caching, payload filtering, and more.
📦 Installation
Run the installer to bootstrap all base classes and configure autoloading:
This command will:
- Copy all base classes, interfaces, and query handlers into your
app/directory - Add
app/Helpers/Helpers.phptocomposer.jsonautoload files - Run
composer dump-autoloadautomatically
🛠 Usage
Examples
📂 Generated Components
| Component | Path |
|---|---|
| Controller | app/Http/Controllers/{Path}/{Name}Controller.php |
| Model | app/Models/{Path}/{Name}.php |
| Service | app/Services/{Path}/{Name}Service.php |
| Repository | app/Repositories/{Path}/{Name}Repository.php |
| Form Requests | app/Http/Requests/{Path}/{Name}StoreRequest.php & UpdateRequest.php |
| Resource | app/Http/Resources/{Path}/{Name}Resource.php |
| Migration | database/migrations/YYYY_MM_DD_create_{names}_table.php |
| Factory | database/factories/{Path}/{Name}Factory.php |
| Seeder | database/seeders/{Path}/{Name}Seeder.php |
| Feature Test | tests/Feature/{Path}/{Name}Test.php |
🏗 Architecture Overview
Every generated CRUD follows a strict 3-layer architecture:
Real-World Example
Controller — HTTP only, no business logic:
Service — orchestrates business logic:
Repository — data access only:
⚡ Query Pipeline — Chain of Responsibility
Every API request through handleApiQueryRequest() passes through this ordered pipeline:
🔍 Query Parameter Reference
Filtering
| Parameter | Description | Example |
|---|---|---|
?q= |
Frontend-friendly shorthand filter | ?q=title=phone |
?where= |
Direct column filter | ?where=status,active |
?orWhere= |
OR column filter | ?orWhere=type,admin |
?operator= |
Comparison operator | ?operator== or ?operator=like |
?exclude= |
Exclude a specific value | ?exclude=status,deleted |
Relation filtering via ?where=:
Frontend shorthand ?q= with pipe-separated conditions:
Complex nested relational query conditions:
?or=true converts multiple ?q= conditions to orWhere:
Sorting
| Parameter | Default | Example |
|---|---|---|
?sortBy= |
created_at |
?sortBy=price |
?sortOrder= |
desc |
?sortOrder=asc |
Safe against SQL injection — column existence is verified against the schema before applying. Skipped if the builder already has an
orderByapplied.
Soft Deletes
| Parameter | Behaviour |
|---|---|
?trashed=with |
Include soft-deleted records |
?trashed=only |
Return only soft-deleted records |
| (omitted) | Exclude soft-deleted records (default) |
Pagination
| Parameter | Default | Description |
|---|---|---|
?page= |
1 |
Current page |
?limit= |
10 |
Records per page |
?limit=all |
— | Returns all records, no pagination |
Response structure:
Relation Loading
Relations are resolved in this priority order:
- Explicit
$witharray passed tohandleApiQueryRequest() - Model-level
$withproperty - Eloquent registered eager loads via
getEagerLoads()
🧰 Helper Functions
Global utility functions available after install:
| Function | Description |
|---|---|
sendSuccessResponse($message, $data, $status) |
Standardized JSON success response |
sendErrorResponse($exception, $status) |
Standardized JSON error response with environment-aware detail |
validationException($payload, $key) |
Throw a ValidationException from array or string |
filterPayload($data, $allowedKeys) |
Keep only allowed keys from an array |
cacheQuery($query, $method, $args, $ttl) |
Execute and cache a query with tag-based invalidation |
generateCacheKey($builder, $request, $tenantId) |
Generate deterministic cache key from query state |
getCreatedAtColumn($builder\|$model) |
Resolve model's CREATED_AT column safely |
getResourceClass($model) |
Auto-resolve {Model}Resource class or fallback to DefaultResource |
deepMerge($original, $new) |
Deep array merge with force-replace support |
processNestedArray($existing, $payload) |
Merge and deduplicate nested arrays by id |
convertStatus($status) |
Convert boolean to 1/0 |
generateUniqueNumber($prefix) |
Generate a unique prefixed identifier |
getFormatedDate($carbon) |
Human-readable date with diff: "2 days ago (14th April at 08:21 AM in 2025)" |
⚙️ Base Classes Installed
After crudify:install, the following are placed in your app/ directory:
📜 Changelog
Please see CHANGELOG for recent changes.
✨ Credits
📜 License
The MIT License (MIT). Please see License File for more information.
All versions of api-crudify with dependencies
laravel/framework Version 12.*
andreaselia/laravel-api-to-postman Version ^2.1.0
cviebrock/eloquent-sluggable Version ^12.0.0
spatie/laravel-package-tools Version ^1.16.4