1. Go to this page and download the library: Download naylonkessler/con-boss 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/ */
naylonkessler / con-boss example snippets
use ConBoss\Container;
$container = new Container();
// Bind a name to a class FQN
$container->bind('name', Some\Class::class);
// Bind an interface FQN to a class FQN
$container->bind(Some\Interface::class, Some\Class::class);
// Bind an interface FQN to a factory closure
$container->bind(Some\Interface::class, function ($container) {
return new \Some\Class();
});
// Bind a variable
$container->bind('$varName', 'Any content');
// Bind an interface FQN to a shared class FQN
$container->share(Shared\Interface::class, Some\Shared\Class::class);
// Get some bind name from container
$some = $container->get('name');
// Get some variable from container
$var = $container->get('$varName');
// Get multiple values from container
list($name, $var) = $container->get(['name', '$varName']);
// Unbind a name from container
$container->unbind('name');
// Check if some bind exists
$exists = $container->has('name');