I just released a new Laravel package called Laravel ReverseKit that helps you build an entire Laravel backend from a single JSON structure β no AI required.
Instead of writing models, controllers, migrations, policies, tests, and resources manually, you define the output (JSON) once, and ReverseKit generates the full backend for you. (github.com)
π What Laravel ReverseKit Does
Laravel ReverseKit takes a JSON structure and generates:
- Models with
$fillable,$casts, and relationships - Migrations with inferred column types
- API Controllers with CRUD methods
- API Resources mirroring your JSON output
- Form Requests for validation
- Policies with ownership checks
- Model Factories and Seeders
- Feature Tests for your endpoints
- API routes registered via
Route::apiResource()(github.com)
π§ How It Works
Create a JSON file describing your expected API response (or provide a JSON string) and run:
php artisan reverse:generate path/to/your.json
You can also use:
- Live API URLs (
--from-url) - OpenAPI/Swagger specs (
--from-openapi) - Postman collections (
--from-postman) - Existing database tables (
--from-database) - Interactive CLI mode (
reverse:interactive) (github.com)
This generates all backend files based on the JSON structure you define β models, controllers, migrations, policies, and more. (github.com)
π¦ Quick Example
With JSON like this:
{
"user": {
"id": 1,
"name": "John Doe",
"email": "john@test.com",
"posts": [
{"id":1,"title":"First Post","body":"Content","published":true}
]
}
}
Running the generate command creates:
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
π Resources
- GitHub: https://github.com/shaqi-labs/laravel-reversekit
- Packagist: https://packagist.org/packages/shaqi-labs/laravel-reversekit
π Why This Helps
Writing all the boilerplate for a new backend β models, migrations, relationships, policies, tests β takes a lot of time and repetitive typing. ReverseKit lets you focus on your domain and let the tool scaffold the rest based on the output you care about.
Top comments (0)