Skip to content

Commit 259d3f8

Browse files
committed
first commit
0 parents  commit 259d3f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6365
-0
lines changed

README.md

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
# Laravel ReverseKit
2+
3+
[![Laravel](https://img.shields.io/badge/Laravel-10%2B%20%7C%2011%2B%20%7C%2012%2B-red.svg)](https://laravel.com)
4+
[![PHP](https://img.shields.io/badge/PHP-8.2%2B-blue.svg)](https://php.net)
5+
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
6+
7+
---
8+
9+
## 🚀 Tagline
10+
11+
**“Write your response JSON. Get your complete Laravel backend.”**
12+
13+
---
14+
15+
## ✨ What is Laravel ReverseKit?
16+
17+
Laravel ReverseKit is a **rule-based scaffolding package** that generates your entire Laravel backend from a JSON structure—**no AI required**.
18+
It’s perfect for:
19+
20+
* Rapid API prototyping
21+
* SaaS apps and microservices
22+
* Learning Laravel conventions
23+
* Reducing repetitive CRUD boilerplate
24+
25+
**Core Idea:** Reverse your development workflow. Instead of writing controllers → responses, define your response first, and let ReverseKit generate the backend.
26+
27+
---
28+
29+
## ⚡ Features
30+
31+
| Feature | Description |
32+
| -------------------------- | ----------------------------------------------------------------------------- |
33+
| **Zero AI Dependencies** | Pure PHP, no external APIs required |
34+
| **Complete Scaffolding** | Models, Controllers, Resources, Requests, Policies, Factories, Seeders, Tests |
35+
| **Smart Type Inference** | Detects types from JSON values |
36+
| **Relationship Detection** | `hasMany` and `belongsTo` from nested structures |
37+
| **Customizable Stubs** | Modify templates for your coding standards |
38+
| **Preview Mode** | See what will be generated without writing files |
39+
| **Multiple Input Sources** | JSON, API URL, OpenAPI/Swagger, Postman, Database |
40+
| **Interactive Mode** | Step-by-step generator prompts for full control |
41+
42+
---
43+
44+
## 💾 Installation
45+
46+
```bash
47+
composer require shaqi-labs/laravel-reversekit
48+
```
49+
50+
Auto-discovery registers the service provider.
51+
Optional publishing:
52+
53+
```bash
54+
# Config file
55+
php artisan vendor:publish --tag=reversekit-config
56+
57+
# Stubs for customization
58+
php artisan vendor:publish --tag=reversekit-stubs
59+
```
60+
61+
---
62+
63+
## ⚙️ Usage
64+
65+
### Generate from JSON File
66+
67+
```bash
68+
php artisan reverse:generate path/to/your.json
69+
```
70+
71+
### Generate from JSON String
72+
73+
```bash
74+
php artisan reverse:generate '{"user":{"id":1,"name":"John"}}'
75+
```
76+
77+
### Preview Mode
78+
79+
```bash
80+
php artisan reverse:generate data.json --preview
81+
```
82+
83+
### Custom Options
84+
85+
```bash
86+
php artisan reverse:generate data.json \
87+
--only=model,migration,controller \
88+
--module=Blog \
89+
--namespace=App\\Domain \
90+
--force
91+
```
92+
93+
### From API URL
94+
95+
```bash
96+
php artisan reverse:generate --from-url=https://api.example.com/users --auth-token=token
97+
```
98+
99+
### From OpenAPI / Postman
100+
101+
```bash
102+
php artisan reverse:generate --from-openapi=spec.yaml
103+
php artisan reverse:generate --from-postman=collection.json
104+
```
105+
106+
### Interactive Mode
107+
108+
```bash
109+
php artisan reverse:interactive
110+
```
111+
112+
Guides you through models, fields, relationships, and generator selection.
113+
114+
---
115+
116+
## 🛠 Generated Components
117+
118+
| Component | Description |
119+
| ------------- | ---------------------------------------- |
120+
| Models | `$fillable`, `$casts`, and relationships |
121+
| Migrations | Column types inferred from JSON |
122+
| Controllers | CRUD methods returning JSON |
123+
| API Resources | Maps models to JSON structure |
124+
| Form Requests | Validation for Store & Update |
125+
| Policies | Ownership checks where applicable |
126+
| Factories | Model factories with Faker |
127+
| Seeders | Intelligent counts based on JSON |
128+
| Feature Tests | Test cases for all CRUD endpoints |
129+
| Routes | Auto-registered via `apiResource` |
130+
131+
---
132+
133+
## 📊 Type & Relationship Mapping
134+
135+
| JSON Value | PHP Type | Migration | Relationship |
136+
| ---------------- | ---------- | --------------------- | ------------ |
137+
| String | string | VARCHAR(255) | - |
138+
| Integer | int | INTEGER | - |
139+
| Boolean | bool | BOOLEAN | - |
140+
| Float | float | DECIMAL(10,2) | - |
141+
| Null | string | nullable() | - |
142+
| ISO 8601 Date | datetime | TIMESTAMP | - |
143+
| Array of Objects | Collection | Foreign key on child | hasMany |
144+
| Nested Object | Model | Foreign key on parent | belongsTo |
145+
146+
**Example:**
147+
148+
```json
149+
{
150+
"user": {
151+
"id": 1,
152+
"posts": [{"id":1,"title":"Hello"}]
153+
}
154+
}
155+
```
156+
157+
Generates:
158+
159+
* `User` model with `hasMany` `posts()`
160+
* `Post` model with `belongsTo` `user()`
161+
* Migration adds `user_id` foreign key
162+
163+
---
164+
165+
## ⚡ Quick Start Example
166+
167+
Input JSON:
168+
169+
```json
170+
{
171+
"user": {
172+
"id": 1,
173+
"name": "John Doe",
174+
"email": "john@test.com",
175+
"posts": [
176+
{"id":1,"title":"First Post","body":"Content","published":true}
177+
]
178+
}
179+
}
180+
```
181+
182+
Run:
183+
184+
```bash
185+
php artisan reverse:generate input.json
186+
```
187+
188+
Generates:
189+
190+
```
191+
app/Models/User.php
192+
app/Models/Post.php
193+
app/Http/Controllers/UserController.php
194+
app/Http/Controllers/PostController.php
195+
app/Http/Resources/UserResource.php
196+
app/Http/Resources/PostResource.php
197+
app/Policies/UserPolicy.php
198+
app/Policies/PostPolicy.php
199+
database/migrations/xxxx_create_users_table.php
200+
database/migrations/xxxx_create_posts_table.php
201+
tests/Feature/UserTest.php
202+
tests/Feature/PostTest.php
203+
routes/api.php
204+
```
205+
206+
---
207+
208+
## ⚙️ Configuration
209+
210+
```php
211+
return [
212+
'generators' => [
213+
'model' => true,
214+
'migration' => true,
215+
'controller' => true,
216+
'resource' => true,
217+
'request' => true,
218+
'policy' => true,
219+
'factory' => true,
220+
'seeder' => true,
221+
'test' => true,
222+
],
223+
'model' => ['use_soft_deletes' => false, 'use_uuid' => false],
224+
'controller' => ['use_form_requests' => true, 'use_policies' => true],
225+
];
226+
```
227+
228+
---
229+
230+
## 🎨 Customize Stubs
231+
232+
Edit published stubs in `resources/stubs/reversekit/` to match your coding style.
233+
234+
---
235+
236+
## ✅ Requirements
237+
238+
* PHP 8.2+
239+
* Laravel 10, 11, 12+
240+
241+
---
242+
243+
## 📜 License
244+
245+
MIT License – Open source, free for commercial projects.
246+
247+
---
248+
249+
Made with ❤️ by **Shaqi Labs**

composer.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "shaqi-labs/laravel-reversekit",
3+
"description": "Generate complete Laravel backend scaffolding from JSON structures",
4+
"version": "1.0.0",
5+
"type": "library",
6+
"license": "MIT",
7+
"keywords": [
8+
"laravel",
9+
"scaffolding",
10+
"generator",
11+
"json",
12+
"api",
13+
"reverse-engineering"
14+
],
15+
"authors": [
16+
{
17+
"name": "Ishtiaq Ahmed",
18+
"email": "rajaishtiaq6@gmail.com"
19+
}
20+
],
21+
"require": {
22+
"php": "^8.2",
23+
"illuminate/support": "^10.0|^11.0|^12.0",
24+
"illuminate/console": "^10.0|^11.0|^12.0",
25+
"illuminate/filesystem": "^10.0|^11.0|^12.0"
26+
},
27+
"require-dev": {
28+
"orchestra/testbench": "^8.0|^9.0|^10.0",
29+
"phpunit/phpunit": "^10.0|^11.0"
30+
},
31+
"autoload": {
32+
"psr-4": {
33+
"Shaqi\\ReverseKit\\": "src/"
34+
}
35+
},
36+
"autoload-dev": {
37+
"psr-4": {
38+
"Shaqi\\ReverseKit\\Tests\\": "tests/"
39+
}
40+
},
41+
"extra": {
42+
"laravel": {
43+
"providers": [
44+
"Shaqi\\ReverseKit\\ReverseKitServiceProvider"
45+
]
46+
}
47+
},
48+
"minimum-stability": "stable",
49+
"prefer-stable": true
50+
}
51+

0 commit comments

Comments
 (0)