1. Go to this page and download the library: Download niirrty/niirrty.pimplewired 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/ */
niirrty / niirrty.pimplewired example snippets
namespace Xyz;
red\WiredContainer;
class Foo
{
public function __toString() : string
{
return '!';
}
}
class User
{
protected $_name;
protected $_foo;
public function __construct( string $name, Foo $foo )
{
$this->_foo = $foo;
$this->_name = $name;
}
public function __toString() : string
{
return $this->_name . $this->_foo;
}
}
class Hello
{
/** @type \Xyz\User */
protected $_user;
public function __construct( User $world )
{
$this->_user = $world;
}
public function output()
{
\printf( 'Hello %s', $this->_user );
}
}
$container = new WiredContainer(
[],
[
'resolve_namespaces' => []
]
);
$container->setCreateArgs(
[
'\Xyz\User' => [ 'World' ]
]
);
$container[ '\Xyz\Hello' ]->output();
$container->setAutoResolve( false );
public function __construct( Foo $foo, Bar $bar ) //…
public function __construct( Foo $foo, string $something, Bar $bar, $blub = null ) //…