shaqi-labs/laravel-reversekit
Composer 安装命令:
composer require shaqi-labs/laravel-reversekit
包简介
Generate complete Laravel backend scaffolding from JSON structures
README 文档
README
🚀 Tagline
“Write your response JSON. Get your complete Laravel backend.”
✨ What is Laravel ReverseKit?
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.
⚡ Features
| 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 |
💾 Installation
composer require shaqi-labs/laravel-reversekit
Note: GitHub username has changed, but the Packagist package name remains the same.
Auto-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-stubs
⚙️ Usage
Generate from JSON File
php artisan reverse:generate path/to/your.json
Generate from JSON String
php artisan reverse:generate '{"user":{"id":1,"name":"John"}}'
Preview Mode
php artisan reverse:generate data.json --preview
Custom Options
php artisan reverse:generate data.json \
--only=model,migration,controller \
--module=Blog \
--namespace=App\\Domain \
--force
From API URL
php artisan reverse:generate --from-url=https://api.example.com/users --auth-token=token
From OpenAPI / Postman
php artisan reverse:generate --from-openapi=spec.yaml php artisan reverse:generate --from-postman=collection.json
Interactive Mode
php artisan reverse:interactive
Guides you through models, fields, relationships, and generator selection.
🛠 Generated Components
| 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 |
📊 Type & Relationship Mapping
| 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
⚡ Quick Start Example
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.json
Generates:
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
⚙️ Configuration
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], ];
🎨 Customize Stubs
Edit published stubs in resources/stubs/reversekit/ to match your coding style.
✅ Requirements
- PHP 8.2+
- Laravel 10, 11, 12+
📜 License
MIT License – Open source, free for commercial projects.
Made with ❤️ by Shaqi Labs
shaqi-labs/laravel-reversekit 适用场景与选型建议
shaqi-labs/laravel-reversekit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 138 次下载、GitHub Stars 达 7, 最近一次更新时间为 2025 年 12 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「json」 「api」 「laravel」 「scaffolding」 「reverse-engineering」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shaqi-labs/laravel-reversekit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shaqi-labs/laravel-reversekit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shaqi-labs/laravel-reversekit 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
A PSR-7 compatible library for making CRUD API endpoints
swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
统计信息
- 总下载量: 138
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-03