PHP code example of ntentan / panie

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

    

ntentan / panie example snippets



ainer = new ntentan\panie\Container();
$fooInstance = $container->resolve(Foo::class);


class Foo
{
    private $bar;

    public function __constructor(Bar $bar) {
        $this->bar = $bar;
    }
}


ainer = new ntentan\panie\Container();
$container->bind(BarInterface::class)->to(BarImplementation::class);
$fooInstance = $container->get(Foo::class);


ainer = new ntentan\panie\Container();
$container->bind(BarInterface::class)->to(function(){
    return new BarImplementation();
});


ainer = new ntentan\panie\Container();
$container->bind(BarInterface::class)->to(BarImplementation::class)->asSingleton();
$fooInstance = $container->get(Foo::class);

$container->setup([
    BarInterface::class => BarImplementation::class
]);

$container->setup([
    BarInterface::class => [function(){ ... }, 'singleton' => true]
]);