1. Go to this page and download the library: Download dsawardekar/encase-php 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/ */
dsawardekar / encase-php example snippets
use Encase\Container;
$container = new Container();
$container->object('logger', new Logger())
->factory('worker', 'Worker');
class Worker {
function needs() {
return array('logger');
}
}
class Worker {
function needs() {
return array('one', 'two', 'three');
}
}
class Worker implements INeeds {
function needs() {
return array('one', 'two', 'three');
}
}
// with $callables
$container->object('key', $callable);
// with an anonymous function
$container->object('key', function($container) {
return 'value';
});