承接 ray/media-query 相关项目开发

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

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

ray/media-query

Composer 安装命令:

composer require ray/media-query

包简介

PHP interface-based SQL framework

README 文档

README

Hand-drawn Ray.MediaQuery logo showing sky, sea, and land separated by horizon and shoreline boundaries.

Ray.MediaQuery

codecov Type Coverage Continuous Integration

Interface-Driven SQL for PHP

Ray.MediaQuery lets SQL be SQL and objects be objects.

Define a PHP interface, attach #[DbQuery], write a SQL file, and Ray.MediaQuery provides the implementation through Ray.Di + AOP. Return types and docblocks drive fetching, hydration, pagination, and post-query result objects.

use Ray\MediaQuery\Annotation\DbQuery;

interface UserQueryInterface
{
    #[DbQuery('user_item')]
    public function item(string $id): ?User;
}

final class User
{
    public function __construct(
        public readonly string $id,
        public readonly string $name,
    ) {}
}
-- sql/user_item.sql
SELECT id, name FROM users WHERE id = :id;
$userQuery = $injector->getInstance(UserQueryInterface::class);
$user = $userQuery->item('user-123');

Why Ray.MediaQuery?

  • Zero implementation code — interfaces become working query objects.
  • SQL-first — use joins, CTEs, window functions, vendor-specific SQL, and query plans directly.
  • Typed PHP results — hydrate rows to entities, typed collections, or custom result objects.
  • Rich domain objects — use factory: classes, including DI-aware factories, to create computed or service-backed objects, such as exposing age from a stored birth_date.
  • Explicit boundaries — SQL files, PHP interfaces, and domain objects remain visible and testable.
  • AI-friendly — no hidden query generation; the contract is readable by humans and tools.

Installation

composer require ray/media-query

Quick Start

use Ray\AuraSqlModule\AuraSqlModule;
use Ray\Di\AbstractModule;
use Ray\Di\Injector;
use Ray\MediaQuery\Annotation\DbQuery;
use Ray\MediaQuery\MediaQuerySqlModule;

final class AppModule extends AbstractModule
{
    protected function configure(): void
    {
        $this->install(new MediaQuerySqlModule(
            interfaceDir: __DIR__ . '/Query',
            sqlDir: __DIR__ . '/sql',
        ));
        $this->install(new AuraSqlModule('sqlite::memory:'));
    }
}

interface TodoQueryInterface
{
    #[DbQuery('todo_add')]
    public function add(string $id, string $title): void;

    /** @return array<Todo> */
    #[DbQuery('todo_list')]
    public function list(): array;
}

$injector = new Injector(new AppModule());
$todoQuery = $injector->getInstance(TodoQueryInterface::class);
$todoQuery->add('todo-1', 'Write SQL');
$todos = $todoQuery->list();

Result Types at a Glance

Declaration Meaning
array List of associative rows
?array + type: 'row' Single associative row or null
/** @return array<User> */ array Hydrated entity list
?User + type: 'row' Single hydrated entity or null
void Execute DML and ignore the result
AffectedRows DML row count
InsertedRow INSERT id and resolved bound values
Pages<User> Lazy paginated hydrated rows
PostQueryInterface Custom post-query result object

Documentation

Start from the Documentation Home. It is the single entry point for the manual, hands-on tutorial, BDR pattern, FAQ, ecosystem links, and AI-oriented reference.

Demo Application

See demo/ for a minimal runnable smoke test of the module wiring. The hands-on tutorial in the documentation site is the full feature walkthrough.

Philosophy

Ray.MediaQuery does not hide SQL to make objects comfortable, and it does not flatten objects to make SQL convenient. It lets both sides do what they are good at: SQL expresses data access precisely, while PHP expresses types, domain behavior, and dependency-injected object construction.

ray/media-query 适用场景与选型建议

ray/media-query 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 252.94k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2021 年 02 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ray/media-query 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ray/media-query 我们能提供哪些服务?
定制开发 / 二次开发

基于 ray/media-query 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 252.94k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 26
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 3
  • Forks: 8
  • 开发语言: PHP

其他信息

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