PHP code example of codejet / bucket

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

    

codejet / bucket example snippets


$delegateLookupContainer = new \League\Container\Container();
$delegateLookupContainer->add('importantSetting', 'This value is only found in the delegate container.');

$bucket = new \CodeJet\Bucket\Bucket();
$bucket->setDelegateContainer($delegateLookupContainer);
$bucket->add(
    'service-id',
    function (\Interop\Container\ContainerInterface $container) {
        // The factory Closure is passed the delegate lookup container.
        return $container->get('importantSetting');
    }
);

var_dump($bucket->get('service-id')); // string(51) "This value is only found in the delegate container."
var_dump($bucket->has('importantSetting')); // bool(false)
 php
$bucket = new CodeJet\Bucket\Bucket();
 php
$bucket->add(
    'service-id',
    function (\Interop\Container\ContainerInterface $bucket) {
        return new \stdClass();
    }
);