binaryk / laravel-restify
Laravel REST API helpers
Installs: 369 153
Dependents: 0
Suggesters: 0
Security: 0
Stars: 627
Watchers: 10
Forks: 59
Open Issues: 1
Requires
- php: ^8.2|^8.3
- illuminate/contracts: ^11.0|^12.0
- laravel/mcp: ^0.1.0
- laravel/pint: ^1.0
- spatie/laravel-data: ^4.4
- spatie/laravel-package-tools: ^1.12
- spatie/once: ^3.0
Requires (Dev)
- brianium/paratest: ^7.0.6
- doctrine/dbal: ^3.0|^4.0
- nunomaduro/collision: ^8.1
- openai-php/laravel: ^0.8.1|^0.11
- orchestra/testbench: ^9.0|^10.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0|^2.0
- phpstan/phpstan-phpunit: ^1.0|^2.0
- phpunit/phpunit: ^10.0|^11.0|^12.0
- spatie/laravel-ray: ^1.9
- vimeo/psalm: ^6.0@dev
Suggests
- nuwave/lighthouse: For GraphQL schema generation and resolvers (^6.0)
- pusher/pusher-php-server: For real-time broadcasting features (^7.0)
- 10.x-dev
- 10.1.12.x-dev
- 10.1.12
- 10.1.11
- 10.1.10
- 10.1.9
- 10.1.8
- 10.1.7
- 10.1.6
- 10.1.5
- 10.1.4
- 10.1.3
- 10.1.2
- 10.1.1
- 10.1.0
- 10.0.2
- 10.0.1
- 10.0.0
- 9.x-dev
- 9.11.3
- 9.11.2
- 9.11.1
- 9.11.0
- 9.10.3
- 9.10.2
- 9.10.1
- 9.10.0
- 9.9.1
- 9.9.0
- 9.8.0
- 9.7.1
- 9.7.0
- 9.6.2
- 9.6.1
- 9.6.0
- 9.5.1
- 9.5.0
- 9.4.0.x-dev
- 9.3.1
- 9.3.0
- 9.2.0
- 9.1.0
- 9.0.0
- 8.x-dev
- 8.4.0
- 8.3.2
- 8.3.1
- 8.3.0
- 8.2.0
- 8.1.5
- 8.1.4.x-dev
- 8.1.3
- 8.1.2.x-dev
- 8.1.2
- 8.1.1
- 8.1.0
- 8.0.1
- 8.0.0
- 7.x-dev
- 7.11.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3.15.0
- 3.14.0
- 3.13.0
- 3.12.2
- 3.12.1
- 3.12.0
- 3.11.0
- 3.10.0
- 3.9.0
- 3.8.0
- 3.7.0
- 3.6.0
- 3.5.1
- 3.5.0
- 3.4.1
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.1
- 3.0.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- dev-feat/docs-architecture
- dev-fix/docs
- dev-fix/profile
- dev-fix/logout
- dev-docs-v3
- dev-binaryk-patch-1
- dev-fix/string-guess
- dev-fix/searchable
- dev-fix/store-update-mcp
- dev-fix/add-field-description
- dev-fix/mcp-array
- dev-fix/sortables
- dev-feat/fields-with-relationships
- dev-sortable
- dev-fix/searchables-join
- dev-fix/relatd-mcp-performance
- dev-tools/profile
- dev-fix/revert-index-method
- dev-fix/retrieve-query-from-input
- dev-fix/uppercase-pgsql
- dev-fix/index-array
- dev-fix/join-search
- dev-query-optimizations
- dev-ai-solutions
- dev-fix-matches2
- dev-fix-matches
- dev-fix/login-user
- dev-fix/adding-related-helpers
- dev-fix/fix-default-callback
- dev-feat/setup-laravel-12
- dev-laravel-12
- dev-fix-loading-nested
- dev-larastan-support
- dev-fixes
- dev-improvement
- dev-master
- dev-routes-fixes
- dev-association-fix
- dev-recursive-related
- dev-related-fix
- dev-custom-serializer
- dev-elastic-fix
- dev-incase-search
- dev-stuff
- dev-getters
- dev-routes-api
- dev-sort-has-one
- dev-sync-5
- dev-docs-test-vuepress
- dev-policies
- dev-standaone_actions
- dev-match-array-date
- dev-match-feature
This package is auto-updated.
Last update: 2025-09-03 10:23:41 UTC
README
Unified Laravel API Layer for Humans and AI
One Codebase. REST for Humans, MCP for AI Agents.
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.
🚀 The Power of One Codebase
Traditional API development requires separate implementations for different consumers. Laravel Restify changes that:
- 👥 Humans get full-featured JSON:API endpoints
- 🤖 AI Agents get structured MCP (Model Context Protocol) servers
- 🔒 Same Rules - All authentication, authorization, and policies apply to both
- 📝 One Definition - Write your repository once, serve everywhere
Key Features
- JSON:API Endpoints - Full JSON:API specification compliance
- MCP Server Generation - Automatic AI agent interfaces with tool definitions
- Unified Authorization - Laravel policies protect both human and AI access
- Search & Filtering - Powerful query capabilities for all consumers
- Authentication - Laravel Sanctum integration for secure access
- GraphQL Support - Auto-generated GraphQL schemas
- Field Validation - Consistent validation rules across all interfaces
Installation
composer require binaryk/laravel-restify
Quick Start
1. Setup the package:
php artisan restify:setup
2. Create your first repository:
php artisan restify:repository PostRepository --all
3. Enable MCP for AI agents (optional):
Add to your config/ai.php
:
use Binaryk\LaravelRestify\MCP\RestifyServer; use Laravel\Mcp\Facades\Mcp; Mcp::web('restify', RestifyServer::class) ->middleware(['auth:sanctum']) ->name('mcp.restify');
That's it! Your API now serves both:
For Humans (JSON:API):
GET /api/restify/posts POST /api/restify/posts PUT /api/restify/posts/1 DELETE /api/restify/posts/1
For AI Agents (MCP):
GET /mcp/restify # Tool definitions and capabilities
Example Repository
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest; use Binaryk\LaravelRestify\Repositories\Repository; use Binaryk\LaravelRestify\Attributes\Model; #[Model(Post::class)] class PostRepository extends Repository { public function fields(RestifyRequest $request): array { return [ field('title')->rules('required', 'string', 'max:255'), textarea('content')->rules('required'), field('author')->readonly(), datetime('published_at')->nullable(), ]; } }
This single definition automatically provides:
- ✅ JSON:API CRUD endpoints with validation
- ✅ MCP tools for AI agents with the same validation
- ✅ Authorization policies applied to both interfaces
- ✅ Search and filtering capabilities for all consumers
One Codebase, Two Outputs
Here's what you get from one repository definition:
For Humans (JSON:API Response)
GET /api/restify/posts
{ "data": [ { "id": "1", "type": "posts", "attributes": { "title": "Laravel Restify Guide", "content": "Build APIs fast...", "published_at": "2024-01-15" } } ], "links": { "self": "/api/restify/posts", "next": "/api/restify/posts?page=2" } }
For AI Agents (MCP Tool Definition)
GET /mcp/restify # Tool definitions for AI agents
{ "tools": [ { "name": "posts-index-tool", "description": "Retrieve a paginated list of Post records from the posts repository with filtering, sorting, and search capabilities.", "inputSchema": { "type": "object", "properties": { "page": { "type": "number", "description": "Page number for pagination" }, "perPage": { "type": "number", "description": "Number of posts per page" }, "search": { "type": "string", "description": "Search term to filter posts by title or content" }, "sort": { "type": "string", "description": "Sorting criteria (e.g., sort=title or sort=-published_at for descending)" }, "title": { "type": "string", "description": "Filter by exact match for title (e.g., title=Laravel). Accepts negation with -title=value" }, "published_at": { "type": "string", "description": "Filter by publication date (e.g., published_at=2024-01-15)" } } } } ] }
All generated from this simple repository:
#[Model(Post::class)] class PostRepository extends Repository { use HasMcpTools; public function fields(RestifyRequest $request): array { return [ field('title')->required()->matchable(), field('content'), field('published_at')->rules('date')->matchable(), ]; } }
Restify Boost
Laravel Restify Boost is a development companion that provides MCP server capabilities to help you build Restify APIs faster with AI assistance.
Repository: laravel-restify-boost
Features:
- Documentation access for AI agents
- Repository and action generation assistance
- Code examples and best practices
- Integration with Claude Desktop and other AI tools
Installation:
composer require --dev binarcode/laravel-restify-boost
Templates
Need a production-ready starting point? Check out Restify Templates for complete API starter kits with authentication, permissions, and team management.
Resources
- Documentation - Complete guides and API reference
- Demo Repository - Working example
- Video Course - Visual learning resource
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email eduard.lupacescu@binarcode.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.