lithemod/orbis 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

lithemod/orbis

最新稳定版本:v1.0.0

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.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固