lithemod/orbis
Composer 安装命令:
composer require lithemod/orbis
包简介
A powerful class manager for effortless instance handling in PHP!
README 文档
README
✨ Lithe Orbis is a powerful class for managing class instances easily and efficiently in PHP!
Installation
You can install Lithe Orbis using Composer. Run the following command in your terminal:
composer require lithemod/orbis
Usage
Registering an Instance
To register an instance of a class, you can use the register method. Here's an example:
use Lithe\Orbis\Orbis; class MyClass { public function sayHello() { return "Hello, World!"; } } // Register a new instance without a key Orbis::register(MyClass::class); // Get the registered instance $instance = Orbis::instance(MyClass::class); echo $instance->sayHello(); // Output: Hello, World!
Registering with a Key
You can also register an instance using a custom key:
$myObject = new MyClass(); Orbis::register($myObject, 'myCustomKey'); // Get the instance using the custom key $instance = Orbis::instance('myCustomKey'); echo $instance->sayHello(); // Output: Hello, World!
Unregistering an Instance
If you need to remove a registered instance, you can use the unregister method:
Orbis::unregister(MyClass::class);
Getting an Instance with Unregistration
The instance method has a second optional parameter that, when set to true, will unregister the instance upon returning it. Here's how it works:
// Register the instance Orbis::register(MyClass::class); // Get and unregister the instance $instance = Orbis::instance(MyClass::class, true); echo $instance->sayHello(); // Output: Hello, World! // The instance is now unregistered
Common Errors
- Class not registered: If you try to get an instance that hasn’t been registered, an error will be thrown.
- Instance already registered: Attempting to register an instance with an existing key will throw an error.
Contribution
Contributions are welcome! Feel free to submit a pull request or open an issue.
License
This project is licensed under the MIT License. See the LICENSE file for details.
lithemod/orbis 适用场景与选型建议
lithemod/orbis 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 350 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 10 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lithemod/orbis 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lithemod/orbis 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 350
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-02