定制 ray/fake-query 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ray/fake-query

Composer 安装命令:

composer require ray/fake-query

包简介

README 文档

README

A companion to Ray.MediaQuery that replaces SQL execution with JSON fixture files — no database required. Designed for testing and frontend development.

Ray.MediaQuery   SQL files  → DB execution → Entity
Ray.FakeQuery    JSON files → hydration    → Entity (same interface)

Installation

composer require ray/fake-query 1.x-dev --dev

Usage

Define query interfaces with #[DbQuery] as usual:

interface TodoQueryInterface
{
    #[DbQuery('todo_item')]
    public function item(string $todoId): ?TodoEntity;

    #[DbQuery('todo_list')]
    /** @return array<TodoEntity> */
    public function list(string $filterStatus = 'all'): array;

    #[DbQuery('todo_add')]
    public function add(string $todoId, string $title): void;
}

Swap modules to switch between real SQL and fake JSON:

// Production
$this->install(new MediaQuerySqlModule($sqlDir, $interfaceDir));

// Test / Frontend development
$this->install(new FakeQueryModule($fakeDir, $interfaceDir));

Create JSON files matching the query ID in #[DbQuery]:

var/fake/todo_item.json — single entity (?Entity):

{
    "todo_id": "01HVXXXXXX0008",
    "todo_title": "Buy groceries"
}

var/fake/todo_list.jsonl — collection (array<Entity>), one object per line:

{"todo_id": "01HVXXXXXX0008", "todo_title": "Buy groceries"}
{"todo_id": "01HVXXXXXX0007", "todo_title": "Call dentist"}

void methods require no file — they succeed silently as no-ops.

JSON keys use snake_case; entity properties use camelCase. Conversion is automatic, matching Ray.MediaQuery behavior.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固