1. Go to this page and download the library: Download luna-fw/container 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/ */
luna-fw / container example snippets
eep the container instance available globally
$djinn = new \Luna\Djinn();
// configure the bindings
$djinn->bind(FooContract::class, function() {
return new FooClass('paramether');
});
// every time you need an instance that implements FooContract, you call the get method
$foo = $djinn->get(FooContract::class);
echo get_class($foo); // prints FooClass
$djinn->bind(FooClass::class, function() {
return new FooClass('paramether');
});
$djinn->bind('barservice', function() {
return new BarClass($djinn->get(FooClass::class));
});
$djinn->singleton(FooClass::class, function() {
return new FooClass('paramether');
});