PHP code example of lassehaslev / universal-objects

1. Go to this page and download the library: Download lassehaslev/universal-objects 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/ */

    

lassehaslev / universal-objects example snippets


class MyClass extends LasseHaslev\UniversalObjects\Object {}

MyClass::create(); // Create new or gets existing instance of my class
// or use alias "get" function
MyClass::get(); // alias for create()

$firstInstance = MyClass::create(); // Creates new instance
$secondInstance = MyClass::create( 'second' ); // Creates new instance

$firstInstance = MyClass::get(); // Get first instance
$secondInstance = MyClass::get( 'second' ); // Get second instance

$firstInstance = MyClass::create(); // Creates new instance
$firstInstance = MyClass::createNew(); // Creates new instance

$firstInstance = MyClass::create(); // Creates new instance
$secondInstance = MyClass::createNew( 'second' ); // Creates new instance

$firstInstance = MyClass::destroy(); // Deletes instance $firstInstance
$secondInstance = MyClass::destroy( 'second' ); // Deletes instance $seondInstance

$firstInstance = MyClass::create(); // Creates new instance
$secondInstance = MyClass::createNew( 'second' ); // Creates new instance

$firstInstance = MyClass::destroyAll(); // Destroy all instances of class ($firstInstance, $secondInstance)