PHP code example of exan / container
1. Go to this page and download the library: Download exan/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/ */
exan / container example snippets
$container = new Exan\Container();
$someClass = $container->get(SomeClass::class);
class SomeClass
{
public function __construct(public readonly Dependency $dependency)
{
// ...
}
}
$container = new Exan\Container();
$someClass = $container->get(SomeClass::class);
interface SomeInterface
{
// ...
}
class SomeClass implements SomeInterface
{
// ...
}
$container = new Exan\Container();
$container->register(SomeInterface::class, new SomeClass())
$someClass = $container->get(SomeInterface::class);