1. Go to this page and download the library: Download codeeverything/burlap 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/ */
// when defined, a service receives the container as it's first argument and it's dependencies thereafter
$sack->mailer_settings(['mailer_user', 'mailer_pass', function ($c, $user, $pass) {
$o = new stdclass();
$o->user = $user . rand();
$o->pass = $pass . rand();
// return a single instance of the service by using Burlap's "share" function
return $c->share('mailer_settings', $o);
}]);
$sack->mailer(['mailer_settings', function ($c, $settings) {
$o = new stdclass();
$o->one = $settings->user;
$o->two = $settings->pass;
$o->three = rand() * 10;
// return a single instance of the service by using Burlap's "share" function
return $c->share('mailer', $o);
}]);
// setup two mailers, since the service is shared these will be identical
$mailer1 = $sack->mailer();
$mailer2 = $sack->mailer();
// dump the list of defined services
var_dump($sack->container);
$mailer = $sack->get('mailer');
$hasMailer = $sack->has('mailer');
// must implement the ContainerInterface
$delegate = new SomeOtherContainer();
$sack = new Burlap($delegate);
// must implement the ContainerInterface
$delegate = new Burlap();
// add a service
$delegate->user([function ($c) {
return '1234';
}]);
// create our Burlap sack, and pass the delegate container
$sack = new Burlap($delegate);
// define a service in Burlap which depends on the service defined in the delegate
// container and pull in the result of that service as $who
$sack->whoAmI(['user', function ($c, $who) {
return "$who: I am not a number, I am a free man";
}]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.