1. Go to this page and download the library: Download koind/dic 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/ */
koind / dic example snippets
use Koind\Container;
use koind\storage\SessionStorage;
ind\storage\StorageInterface', function (Container $container) {
return new SessionStorage('cart');
});
$container->set('koind\cost\CalculatorInterface', 'koind\cost\SimpleCost');
$container->setShared('cart', 'koind\Cart');
// implementation logic
$cart = $container->get('cart');
$cart->add(5, 6, 100);
public function set(string $name, $value): void
public function setShared(string $name, $value): void
public function get(string $name): object
$container->set('koind\storage\StorageInterface', function (Container $container) {
return new SessionStorage('cart');
});
// Get component SessionStorage by name:
$container->get('koind\storage\StorageInterface');
$container->set('koind\cost\CalculatorInterface', 'koind\cost\SimpleCost');
// Get component SimpleCost by name:
$container->get('koind\storage\CalculatorInterface');
$container->setShared('koind\storage\StorageInterface', function (Container $container) {
return new SessionStorage('cart');
});
// Get component SessionStorage by name:
$container->get('koind\storage\StorageInterface');
$container->setShared('koind\cost\CalculatorInterface', 'koind\cost\SimpleCost');
// Get component SimpleCost by name:
$container->get('koind\storage\CalculatorInterface');