承接 taujor/cally 相关项目开发

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

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

taujor/cally

Composer 安装命令:

composer require taujor/cally

包简介

Cally is a lightweight, immutable registry for storing and retrieving data or services in PHP. It provides a simple yet powerful way to manage configurations, dependencies, or any key-value pairs with support for immutability and PSR-11 compliance. Cally is ideal for any project where a full-fledged

README 文档

README

Cally is a minimal, elegant, and strict PSR-11–compatible service locator for PHP 8+.
It provides a simple API for defining services, factories, singletons, lazy-loaded objects, and values.

Cally is designed to be:

  • Small – no dependencies
  • Predictable – explicit, no magic
  • Strict – throws meaningful exceptions
  • PSR-11 compliant – works with existing standards
  • Fast – closures only, no reflection

Features

  • PSR-11 ContainerInterface compatible
  • Register lazy-loaded services
  • Register singletons
  • Register factories
  • Register simple values
  • Freeze the container to prevent modification
  • Meaningful exception hierarchy:
    • FrozenRegistryException
    • KeyAlreadyExistsException
    • KeyNotFoundException

Missing Essentials

  • No circular dependency detection - Lazy services could create infinite loops if A depends on B depends on A
  • No error context - Exceptions don't capture which dependency failed during complex resolution chains
  • No type safety - Can't specify/validate what type a key should return
  • No autowiring - Must manually register everything (fine for simple apps, tedious for large ones)
  • No container awareness - Factories can't receive the container itself to resolve their own dependencies
  • No unfreeze/clear - Once frozen, you're stuck (problematic for testing)

Debatable Missing Features

  • Aliases - Point multiple keys to same service
  • Tags/groups - Retrieve all services of a certain type
  • Service decoration/extension - Wrap existing services
  • Performance - No caching of resolution paths for complex dependency graphs

Production Readiness

For a small-to-medium application with straightforward dependencies, it's probably fine. For production at scale, you'd likely want at least circular dependency detection and better error context. The rest depends on your specific needs.

Future

I plan to implement all missing features (and possibly some debatable ones) in future, while also staying commited to Cally's minimalistic nature.

Installation

Install via Composer:

composer require taujor/cally

Quick Start

Create the container

use Taujor\Cally\Cally;

$container = new Cally();

Registering Services

Singleton

A single shared instance:

$pdo = new PDO('sqlite::memory:');

$container->singleton('db', $pdo);

Usage:

$db = $container->get('db'); // always returns the same instance

Lazy Service

Instantiated only once on first use:

$container->lazy('config', function () {
    return parse_ini_file('app.ini');
});

Factory

Produces a new instance every time:

$container->factory('uuid', fn() => bin2hex(random_bytes(16)));

$id1 = $container->get('uuid');
$id2 = $container->get('uuid');

// always different

Value

Stores a simple immutable value:

$container->value('version', '1.0.0');

echo $container->get('version'); // "1.0.0"

Retrieving Services

$service = $container->get('key');

If the key does not exist:
KeyNotFoundException

Checking Keys

if ($container->has('cache')) {
    // ...
}

Freezing the Container

After freezing the container, no new services can be registered.

$container->freeze();

$container->set('foo', fn() => 'bar'); 
// Throws FrozenRegistryException

Error Handling

Cally throws clear, meaningful exceptions:

Exception Trigger
FrozenRegistryException Attempt to modify a frozen container
KeyAlreadyExistsException Attempt to overwrite a key
KeyNotFoundException Attempt to get a missing key

All exceptions implement PSR-11 interfaces where appropriate.

Why Cally?

  • No unnecessary abstraction layers
  • A clean alternative to overly complex DI containers
  • Explicit over magic

License

MIT license

taujor/cally 适用场景与选型建议

taujor/cally 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 7, 最近一次更新时间为 2025 年 11 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 taujor/cally 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-17