Skip to content

Commit 9f78e8f

Browse files
committed
fix: merge
2 parents 5ccbae6 + 0b5b708 commit 9f78e8f

39 files changed

+485
-4325
lines changed

README.md

Lines changed: 40 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -1,242 +1,97 @@
11
<p align="center"><img src="/docs-v2/static/logo.png"></p>
22

33
<p align="center">
4-
<a href="https://github.com/BinarCode/laravel-restify/actions"><img src="https://github.com/BinarCode/laravel-restify/actions/workflows/tests.yml/badge.svg" alt="Build Status"></a>
4+
<a href="https://github.com/BinarCode/laravel-restify/actions"><img src="https://github.com/BinarCode/laravel-restify/workflows/tests/badge.svg" alt="Build Status"></a>
55
<a href="https://packagist.org/packages/binaryk/laravel-restify"><img src="https://poser.pugx.org/binaryk/laravel-restify/d/total.svg" alt="Total Downloads"></a>
66
<a href="https://packagist.org/packages/binaryk/laravel-restify"><img src="https://poser.pugx.org/binaryk/laravel-restify/v/stable.svg" alt="Latest Stable Version"></a>
77
<a href="https://packagist.org/packages/binaryk/laravel-restify"><img src="https://poser.pugx.org/binaryk/laravel-restify/license.svg" alt="License"></a>
88
</p>
99

10-
# Unified Laravel API Layer for Humans and AI
10+
The first fully customizable Laravel [JSON:API](https://jsonapi.org) builder. "CRUD" and protect your resources with 0 (zero) extra line of code.
1111

12-
**One Codebase. REST for Humans, MCP for AI Agents.**
13-
14-
Laravel Restify turns your Eloquent models into both JSON:API endpoints and MCP servers -- automatically. Build once, and instantly serve APIs that work seamlessly for developers, apps, and AI agents.
15-
16-
## 🚀 The Power of One Codebase
17-
18-
Traditional API development requires separate implementations for different consumers. Laravel Restify changes that:
19-
20-
- **👥 Humans** get full-featured JSON:API endpoints
21-
- **🤖 AI Agents** get structured MCP (Model Context Protocol) servers
22-
- **🔒 Same Rules** - All authentication, authorization, and policies apply to both
23-
- **📝 One Definition** - Write your repository once, serve everywhere
24-
25-
## Key Features
26-
27-
- **JSON:API Endpoints** - Full [JSON:API](https://jsonapi.org) specification compliance
28-
- **MCP Server Generation** - Automatic AI agent interfaces with tool definitions
29-
- **Unified Authorization** - Laravel policies protect both human and AI access
30-
- **Search & Filtering** - Powerful query capabilities for all consumers
31-
- **Authentication** - Laravel Sanctum integration for secure access
32-
- **GraphQL Support** - Auto-generated GraphQL schemas
33-
- **Field Validation** - Consistent validation rules across all interfaces
12+
<div>
13+
<a href="https://supportukrainenow.org">
14+
<img alt="Support Ukraine" src="https://github-ads.s3-eu-central-1.amazonaws.com/support-ukraine-spatie-be.svg">
15+
</a>
16+
</div>
3417

3518
## Installation
3619

20+
You can install the package via composer:
21+
3722
```bash
3823
composer require binaryk/laravel-restify
3924
```
4025

41-
## Quick Start
42-
43-
**1. Setup the package:**
44-
```bash
45-
php artisan restify:setup
46-
```
26+
## Playground
4727

48-
**2. Create your first repository:**
49-
```bash
50-
php artisan restify:repository PostRepository --all
51-
```
28+
You can find a playground in the [Restify Demo GitHub repository](https://github.com/BinarCode/restify-demo).
5229

53-
**3. Enable MCP for AI agents (optional):**
30+
## Videos
5431

55-
Add to your `config/ai.php`:
56-
```php
57-
use Binaryk\LaravelRestify\MCP\RestifyServer;
58-
use Laravel\Mcp\Facades\Mcp;
32+
If you are a visual learner, checkout [our video course](https://www.binarcode.com/learn/restify) for the Laravel Restify.
5933

60-
Mcp::web('restify', RestifyServer::class)
61-
->middleware(['auth:sanctum'])
62-
->name('mcp.restify');
63-
```
34+
## Quick start
6435

65-
**That's it!** Your API now serves both:
36+
Setup package:
6637

67-
**For Humans (JSON:API):**
6838
```bash
69-
GET /api/restify/posts
70-
POST /api/restify/posts
71-
PUT /api/restify/posts/1
72-
DELETE /api/restify/posts/1
39+
php artisan restify:setup
7340
```
7441

75-
**For AI Agents (MCP):**
76-
```bash
77-
GET /mcp/restify # Tool definitions and capabilities
78-
```
42+
Generate repository:
7943

80-
## Example Repository
81-
82-
```php
83-
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
84-
use Binaryk\LaravelRestify\Repositories\Repository;
85-
use Binaryk\LaravelRestify\Attributes\Model;
86-
87-
#[Model(Post::class)]
88-
class PostRepository extends Repository
89-
{
90-
public function fields(RestifyRequest $request): array
91-
{
92-
return [
93-
field('title')->rules('required', 'string', 'max:255'),
94-
textarea('content')->rules('required'),
95-
field('author')->readonly(),
96-
datetime('published_at')->nullable(),
97-
];
98-
}
99-
}
44+
```bash
45+
php artisan restify:repository Dream --all
10046
```
10147

102-
This single definition automatically provides:
103-
- ✅ JSON:API CRUD endpoints with validation
104-
- ✅ MCP tools for AI agents with the same validation
105-
- ✅ Authorization policies applied to both interfaces
106-
- ✅ Search and filtering capabilities for all consumers
48+
Now you have the REST CRUD over dreams and this beautiful repository:
10749

108-
## One Codebase, Two Outputs
50+
<p align="center"><img src="/docs-v2/static/tile.png"></p>
10951

110-
Here's what you get from one repository definition:
52+
Now you can go into Postman and check it out:
11153

112-
### For Humans (JSON:API Response)
11354
```bash
114-
GET /api/restify/posts
115-
```
116-
117-
```json
118-
{
119-
"data": [
120-
{
121-
"id": "1",
122-
"type": "posts",
123-
"attributes": {
124-
"title": "Laravel Restify Guide",
125-
"content": "Build APIs fast...",
126-
"published_at": "2024-01-15"
127-
}
128-
}
129-
],
130-
"links": {
131-
"self": "/api/restify/posts",
132-
"next": "/api/restify/posts?page=2"
133-
}
134-
}
55+
GET: http://laravel.test/api/restify/dreams
13556
```
13657

137-
### For AI Agents (MCP Tool Definition)
13858
```bash
139-
GET /mcp/restify # Tool definitions for AI agents
59+
POST: http://laravel.test/api/restify/dreams
14060
```
14161

142-
```json
143-
{
144-
"tools": [
145-
{
146-
"name": "posts-index-tool",
147-
"description": "Retrieve a paginated list of Post records from the posts repository with filtering, sorting, and search capabilities.",
148-
"inputSchema": {
149-
"type": "object",
150-
"properties": {
151-
"page": {
152-
"type": "number",
153-
"description": "Page number for pagination"
154-
},
155-
"perPage": {
156-
"type": "number",
157-
"description": "Number of posts per page"
158-
},
159-
"search": {
160-
"type": "string",
161-
"description": "Search term to filter posts by title or content"
162-
},
163-
"sort": {
164-
"type": "string",
165-
"description": "Sorting criteria (e.g., sort=title or sort=-published_at for descending)"
166-
},
167-
"title": {
168-
"type": "string",
169-
"description": "Filter by exact match for title (e.g., title=Laravel). Accepts negation with -title=value"
170-
},
171-
"published_at": {
172-
"type": "string",
173-
"description": "Filter by publication date (e.g., published_at=2024-01-15)"
174-
}
175-
}
176-
}
177-
}
178-
]
179-
}
62+
```bash
63+
GET: http://laravel.test/api/restify/dreams/1
18064
```
18165

182-
**All generated from this simple repository:**
183-
```php
184-
#[Model(Post::class)]
185-
class PostRepository extends Repository
186-
{
187-
use HasMcpTools;
188-
189-
public function fields(RestifyRequest $request): array
190-
{
191-
return [
192-
field('title')->required()->matchable(),
193-
field('content'),
194-
field('published_at')->rules('date')->matchable(),
195-
];
196-
}
197-
}
66+
```bash
67+
PUT: http://laravel.test/api/restify/dreams/1
19868
```
19969

200-
## Restify Boost
201-
202-
**Laravel Restify Boost** is a development companion that provides MCP server capabilities to help you build Restify APIs faster with AI assistance.
203-
204-
**Repository:** [laravel-restify-boost](https://github.com/BinarCode/laravel-restify-boost)
205-
206-
**Features:**
207-
- Documentation access for AI agents
208-
- Repository and action generation assistance
209-
- Code examples and best practices
210-
- Integration with Claude Desktop and other AI tools
211-
212-
**Installation:**
21370
```bash
214-
composer require --dev binarcode/laravel-restify-boost
71+
DELETE: http://laravel.test/api/restify/dreams/1
21572
```
21673

217-
## Templates
218-
219-
Need a production-ready starting point? Check out [Restify Templates](https://restifytemplates.com) for complete API starter kits with authentication, permissions, and team management.
220-
221-
## Resources
74+
## Usage
22275

223-
- **[Documentation](https://laravel-restify.com)** - Complete guides and API reference
224-
- **[Demo Repository](https://github.com/BinarCode/restify-demo)** - Working example
225-
- **[Video Course](https://www.binarcode.com/learn/restify)** - Visual learning resource
76+
See the [official documentation](https://restify.binarcode.com).
22677

227-
## Testing
78+
### Testing
22879

229-
```bash
80+
``` bash
23081
composer test
23182
```
23283

84+
### Changelog
85+
86+
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
87+
23388
## Contributing
23489

23590
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
23691

237-
## Security
92+
### Security
23893

239-
If you discover any security related issues, please email eduard.lupacescu@binarcode.com instead of using the issue tracker.
94+
If you discover any security related issues, please email eduard.lupacescu@binarcode.com or [message me on twitter](https://twitter.com/LupacescuEuard) instead of using the issue tracker.
24095

24196
## Credits
24297

@@ -247,3 +102,4 @@ If you discover any security related issues, please email eduard.lupacescu@binar
247102
## License
248103

249104
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
105+

0 commit comments

Comments
 (0)