承接 esanj/remote-eloquent 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

esanj/remote-eloquent

最新稳定版本:v0.1.1

Composer 安装命令:

composer require esanj/remote-eloquent

包简介

A Laravel package that extends Eloquent ORM to work with remote APIs (REST and gRPC)

README 文档

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);

🧩 Supported Methods

RemoteEloquent supports commonly used Eloquent query builder methods for interacting with remote gRPC APIs.

Method Description
where Apply a basic “where” condition to the query.
whereIn Filter results where a column’s value is within a given array of values.
whereBetween Filter results between two values for a specific column.
find Retrieve a model by its primary key.
findOrFail Retrieve a model by its primary key or throw an exception if not found.
get Execute the query and return all matching records as a collection.
paginate Retrieve paginated results from the remote API.
count Retrieve the total number of matching records.
avg Calculate the average of a given column.
sum Calculate the sum of a given column.

🔧 More Eloquent query methods are planned for future releases.

License

MIT © Esanj

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-09