PHP code example of lithemod / orbis

1. Go to this page and download the library: Download lithemod/orbis library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lithemod / orbis example snippets


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!

$myObject = new MyClass();
Orbis::register($myObject, 'myCustomKey');

// Get the instance using the custom key
$instance = Orbis::instance('myCustomKey');
echo $instance->sayHello(); // Output: Hello, World!

Orbis::unregister(MyClass::class);

// 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