PHP code example of xtompie / lainstance
1. Go to this page and download the library: Download xtompie/lainstance 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/ */
xtompie / lainstance example snippets
use Xtompie\Lainstance\Instance;
class Foo
{
use Instance;
}
$foo = Foo::instance();
use Xtompie\Lainstance\Instance;
class Bar
{
}
class Foo
{
use Instance;
public function __construct(
public Bar $bar
) {}
}
$foo = Foo::instance();
echo get_class($foo->bar); // => Bar
use Xtompie\Lainstance\Instance;
use Xtompie\Lainstance\Shared;
class Foo implements Shared
{
use Instance;
}
echo Foo::instance() === Foo::instance(); // => 1