PHP code example of xtreamwayz / pimple-container-interop

1. Go to this page and download the library: Download xtreamwayz/pimple-container-interop 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/ */

    

xtreamwayz / pimple-container-interop example snippets


use Xtreamwayz\Pimple\Container;

$container = new Container();

$container = new Xtreamwayz\Pimple\Container;
$container['hi'] = 'welcome';

$delegate1 = new Acme\Container\DelegateContainer;
$delegate1['foo'] = 'bar';
$container->delegate($delegate1);

$delegate2 = new Xtreamwayz\Pimple\Container;
$delegate2['baz'] = 'qux';
$container->delegate($delegate2);

// Resolve dependency from main $container
$container->has('hi'); // true
$container->get('hi'); // returns 'welcome';

// Resolve dependency from $delegate1
$container->has('foo'); // true
$container->get('foo'); // returns 'bar';

// Resolve dependency from $delegate2
$container->has('baz'); // true
$container->get('baz'); // returns 'qux';