1. Go to this page and download the library: Download decodelabs/pandora 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/ */
decodelabs / pandora example snippets
use DecodeLabs\Pandora\Container;
$container = new Container();
use My\Library\CoolInterface;
use My\Library\CoolImplementation; // Implements CoolInterface
// Instance
$container->bind(CoolInterface::class, new CoolImplementation());
$imp = $container->get(CoolInterface::class);
// Will only bind if CoolInterface has not been bound before
$container->tryBind(CoolInterface::class, new OtherImplementation()); // Will not bind
$imp = $container->get(CoolInterface::class);
// Bind a factory
$container->bind(CoolInterface::class, fn() => new CoolImplementation());
$imp = $container->getWith(CoolInterface::class, ['list', 'of', 'params']);
// Or inject parameters for later:
$container->inject(CoolInterface::class, 'paramName', 'paramValue');
$imp = $container->get(CoolInterface::class);