DEV Community

Cover image for Laravel ReverseKit: Generate Your Entire Laravel Backend From a JSON Structure
Ishtiaq Ahmed
Ishtiaq Ahmed

Posted on

Laravel ReverseKit: Generate Your Entire Laravel Backend From a JSON Structure

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
Enter fullscreen mode Exit fullscreen mode

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}
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

πŸ“ Resources


πŸ›  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)