esanj / remote-eloquent
A Laravel package that extends Eloquent ORM to work with remote APIs (REST and gRPC)
v0.1.1
2025-09-17 09:55 UTC
Requires
- php: ^8.0
- google/protobuf: ^4.30
- grpc/grpc: ^1.57
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0
- phpunit/phpunit: ^9.0|^10.0
Suggests
- google/protobuf: Required for gRPC support
- grpc/grpc: Required for gRPC support
README
A Laravel package that extends the Eloquent ORM to seamlessly interact with remote APIs (REST and gRPC) as if they were local databases.
Features
- REST & gRPC Support: Use Eloquent models to communicate with remote RESTful or gRPC APIs.
- Familiar Eloquent Syntax: Continue using Eloquent's expressive syntax for remote data sources.
- Easy Integration: Plug-and-play with Laravel 9, 10, and 11.
- Extensible & Configurable: Easily customize endpoints, authentication, and serialization.
Requirements
- PHP >= 8.0
- Laravel 9.x, 10.x, or 11.x, or 12.x
- guzzlehttp/guzzle ^7.0
- illuminate/support ^9.0|^10.0|^11.0|^12.x
Installation
composer require esanj/remote-eloquent
Configuration
Publish the package configuration (if available):
php artisan vendor:publish --provider="Esanj\\RemoteEloquent\\Providers\\RemoteEloquentServiceProvider"
Edit the configuration file in config/remote-eloquent.php
to set your API endpoints, authentication, and other
options.
Usage
Creating a Remote Model
Extend your model from Esanj\RemoteEloquent\RemoteModel
instead of the default Eloquent Model:
use Esanj\RemoteEloquent\RemoteModel; class UserModel extends RemoteModel { public string $address = '127.0.0.1:50051'; protected string $clientType = 'grpc'; }
Querying Remote Data
// Paginate Users List $users = UserModel::where('is_active',1)->where('age', '>', 10)->paginate(); // Find a user by ID $user = UserModel::find(1);
License
MIT © Esanj