PHP code example of downing / tupper
1. Go to this page and download the library: Download downing/tupper 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/ */
downing / tupper example snippets
$ioc = new Downing\Tupper\IoC();
// Binding a string
$ioc->whenGiven("foo")
->provide("bar");
// Binding a closure, which will be executed when requested from the container
$ioc->whenGiven(YourAbstraction::class)
->provide(function() {
return new YourImplementation();
});
// You can even bind an array
$ioc->whenGiven([1, 2, 3])
->provide([3, 2, 1]);