Requires PHP 5.6
WordPress Container.
composer require frozzare/tank
use Frozzare\Tank\Container;
class Plugin_Loader extends Container {
public function __construct() {
$this->bind( 'number', 12345 );
}
}
$loader = new Plugin_Loader;
echo $loader->make( 'number' );
// 12345
Check the container source code for methods that can be used.
use Frozzare\Tank\Container;
use Frozzare\Tank\Service_Provider;
class Example_Provider extends Service_Provider {
public function register() {
$this->container->bind( 'say', 'Hello!' );
}
}
$container = new Container;
$provider = new Example_Provider( $container );
$provider->register();
echo $container->make( 'say' );
// Hello!
MIT © Fredrik Forsmo