“Write your response JSON. Get your complete Laravel backend.”
Laravel ReverseKit is a rule-based scaffolding package that generates your entire Laravel backend from a JSON structure—no AI required. It’s perfect for:
- Rapid API prototyping
- SaaS apps and microservices
- Learning Laravel conventions
- Reducing repetitive CRUD boilerplate
Core Idea: Reverse your development workflow. Instead of writing controllers → responses, define your response first, and let ReverseKit generate the backend.
| Feature | Description |
|---|---|
| Zero AI Dependencies | Pure PHP, no external APIs required |
| Complete Scaffolding | Models, Controllers, Resources, Requests, Policies, Factories, Seeders, Tests |
| Smart Type Inference | Detects types from JSON values |
| Relationship Detection | hasMany and belongsTo from nested structures |
| Customizable Stubs | Modify templates for your coding standards |
| Preview Mode | See what will be generated without writing files |
| Multiple Input Sources | JSON, API URL, OpenAPI/Swagger, Postman, Database |
| Interactive Mode | Step-by-step generator prompts for full control |
composer require shaqi-labs/laravel-reversekitAuto-discovery registers the service provider. Optional publishing:
# Config file php artisan vendor:publish --tag=reversekit-config # Stubs for customization php artisan vendor:publish --tag=reversekit-stubsphp artisan reverse:generate path/to/your.jsonphp artisan reverse:generate '{"user":{"id":1,"name":"John"}}'php artisan reverse:generate data.json --previewphp artisan reverse:generate data.json \ --only=model,migration,controller \ --module=Blog \ --namespace=App\\Domain \ --forcephp artisan reverse:generate --from-url=https://api.example.com/users --auth-token=tokenphp artisan reverse:generate --from-openapi=spec.yaml php artisan reverse:generate --from-postman=collection.jsonphp artisan reverse:interactiveGuides you through models, fields, relationships, and generator selection.
| Component | Description |
|---|---|
| Models | $fillable, $casts, and relationships |
| Migrations | Column types inferred from JSON |
| Controllers | CRUD methods returning JSON |
| API Resources | Maps models to JSON structure |
| Form Requests | Validation for Store & Update |
| Policies | Ownership checks where applicable |
| Factories | Model factories with Faker |
| Seeders | Intelligent counts based on JSON |
| Feature Tests | Test cases for all CRUD endpoints |
| Routes | Auto-registered via apiResource |
| JSON Value | PHP Type | Migration | Relationship |
|---|---|---|---|
| String | string | VARCHAR(255) | - |
| Integer | int | INTEGER | - |
| Boolean | bool | BOOLEAN | - |
| Float | float | DECIMAL(10,2) | - |
| Null | string | nullable() | - |
| ISO 8601 Date | datetime | TIMESTAMP | - |
| Array of Objects | Collection | Foreign key on child | hasMany |
| Nested Object | Model | Foreign key on parent | belongsTo |
Example:
{ "user": { "id": 1, "posts": [{"id":1,"title":"Hello"}] } }Generates:
Usermodel withhasManyposts()Postmodel withbelongsTouser()- Migration adds
user_idforeign key
Input JSON:
{ "user": { "id": 1, "name": "John Doe", "email": "john@test.com", "posts": [ {"id":1,"title":"First Post","body":"Content","published":true} ] } }Run:
php artisan reverse:generate input.jsonGenerates:
app/Models/User.php app/Models/Post.php app/Http/Controllers/UserController.php app/Http/Controllers/PostController.php app/Http/Resources/UserResource.php app/Http/Resources/PostResource.php app/Policies/UserPolicy.php app/Policies/PostPolicy.php database/migrations/xxxx_create_users_table.php database/migrations/xxxx_create_posts_table.php tests/Feature/UserTest.php tests/Feature/PostTest.php routes/api.php return [ 'generators' => [ 'model' => true, 'migration' => true, 'controller' => true, 'resource' => true, 'request' => true, 'policy' => true, 'factory' => true, 'seeder' => true, 'test' => true, ], 'model' => ['use_soft_deletes' => false, 'use_uuid' => false], 'controller' => ['use_form_requests' => true, 'use_policies' => true], ];Edit published stubs in resources/stubs/reversekit/ to match your coding style.
- PHP 8.2+
- Laravel 10, 11, 12+
MIT License – Open source, free for commercial projects.
Made with ❤️ by Shaqi Labs