PHP code example of zorachka / container
1. Go to this page and download the library: Download zorachka/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/ */
zorachka / container example snippets
declare(strict_types=1);
use Psr\Container\ContainerInterface;
use Zorachka\Container\ContainerFactory;
use Zorachka\Container\ServiceProvider;
$container = ContainerFactory::build([
new class implements ServiceProvider {
/**
* @inheritDoc
*/
public static function getDefinitions(): array
{
return [
stdClass::class => static fn() => new stdClass(),
];
}
/**
* @inheritDoc
*/
public static function getExtensions(): array
{
return [
stdClass::class => static function ($stdClass, ContainerInterface $container): stdClass {
$stdClass->property = 'value';
return $stdClass;
}
];
}
}
]);