<?php
use Illuminate\Container\Container;
$container = new Container();
// binding closure to container
$container->bind('helloworld', function() {
return 'Hello World';
});
echo $container->make('helloworld') . PHP_EOL;
// or
echo $container['helloworld'] . PHP_EOL;
$container->bind('ao', function() {
return new ArrayObject([1,2,4,8]);
});
$container->bind('iterator', function($container) {
return new IteratorIterator($container->make('ao'));
});
$iterator = $container->make('iterator');
foreach ($iterator as $val) {
echo $val . PHP_EOL;
}