定制 martincamen/php-arr-core 二次开发

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

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

martincamen/php-arr-core

Composer 安装命令:

composer require martincamen/php-arr-core

包简介

Canonical domain models and value objects for the *arr ecosystem

README 文档

README

Important

This project is still being developed and breaking changes might occur even between patch versions.

The aim is to follow semantic versioning as soon as possible.

A canonical domain model for the *arr ecosystem.

php-arr-core provides shared domain models, value objects, enums and normalization logic used across *arr service SDKs such as Sonarr, Radarr, Jellyseerr and NZBGet.

The goal is to eliminate duplicated DTOs, inconsistent status handling and ad-hoc mappings between services that conceptually model the same things.

Ecosystem

Package Description
radarr-php PHP SDK for Radarr
sonarr-php PHP SDK for Sonarr
jellyseerr-php PHP SDK for Jellyseerr
laravel-radarr Laravel integration for Radarr
laravel-sonarr Laravel integration for Sonarr
laravel-jellyseerr Laravel integration for Jellyseerr

Why does this exist?

The *arr ecosystem is highly cohesive:

  • Sonarr, Radarr, Jellyseerr and NZBGet all model:
    • media (movies, series, episodes)
    • downloads (queue items)
    • file sizes
    • progress
    • statuses
  • Yet each service exposes these concepts using:
    • different naming
    • different units
    • different status values
    • different lifecycle semantics

This results in:

  • duplicated DTOs
  • repeated status mapping logic
  • fragile integrations
  • inconsistent developer experience

php-arr-core solves this by defining one canonical domain model that all *arr SDKs map to.

What this package is

  • ✅ Pure PHP (no framework dependencies)
  • ✅ Canonical domain models
  • ✅ Value objects (FileSize, Duration, Progress, etc.)
  • ✅ Normalized enums and statuses
  • ✅ Mapping helpers and contracts

Core design principles

1. Canonical domain > API representation

APIs change. Domains evolve slowly.

This package models what things are, not how services expose them.

2. Value objects over primitives

Anything that:

  • has units
  • appears in multiple services
  • requires conversion or logic

...is modeled as a value object.

Examples:

  • ArrFileSize (extends martincamen/php-file-size)
  • Duration
  • Progress

3. Status normalization is centralized

Each service uses its own status vocabulary.

All normalization happens once, in core.

SDKs should never contain switch or if blocks for statuses.

4. Mapping happens at the boundary

Service SDKs are responsible for mapping their API DTOs into php-arr-core domain objects.

Core never depends on service-specific code.

Package structure

src/
├── Domain/
│   ├── Media/
│   ├── Download/
│   ├── Request/
│   └── User/
├── ValueObject/
│   ├── ArrFileSize.php
│   ├── Duration.php
│   ├── Progress.php
│   └── ArrId.php
├── Enum/
│   ├── MediaStatus.php
│   ├── DownloadStatus.php
│   └── Service.php
├── Mapping/
│   ├── StatusNormalizer.php
│   └── ServiceCapabilities.php

Example usage

use MartinCamen\ArrCore\Domain\Download\DownloadItem;
use MartinCamen\ArrCore\ValueObject\ArrFileSize;
use MartinCamen\ArrCore\ValueObject\Progress;
use MartinCamen\ArrCore\Enum\DownloadStatus;

$item = new DownloadItem(
    id: ArrId::fromInt(123),
    name: 'Example.Movie.2024',
    size: ArrFileSize::fromGigabytes(8.5),
    progress: Progress::fromPercentage(42),
    status: DownloadStatus::Downloading
);

How service SDKs integrate

Each service SDK:

  1. Defines API-specific DTOs
  2. Fetches raw data via HTTP
  3. Maps DTOs → php-arr-core domain models

Example:

use MartinCamen\Sonarr\Sonarr;

$sonarr = Sonarr::create('localhost', 8989, 'your-api-key');

// Action-based API returns typed responses
$downloads = $sonarr->downloads()->all();   // DownloadPage
$series = $sonarr->series()->all();          // SeriesCollection
$status = $sonarr->system()->status();       // SystemStatus

Supported services

This package is designed to be used by:

  • Sonarr SDK
  • Radarr SDK
  • Jellyseerr SDK
  • NZBGet SDK
  • Prowlarr SDK (planned)

Versioning & stability

php-arr-core follows semantic versioning.

Breaking changes only occur when:

  • a domain concept changes
  • a value object's behavior changes

New services and fields should be additive whenever possible.

Contributing

Contributions are welcome, especially:

  • new value objects
  • improved normalization
  • additional service mappings

Before adding new models, consider:

Is this a domain concept or an API detail?

If unsure, open an issue.

martincamen/php-arr-core 适用场景与选型建议

martincamen/php-arr-core 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「media」 「automation」 「arr」 「nzbget」 「sonarr」 「radarr」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 martincamen/php-arr-core 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-30