1. Go to this page and download the library: Download mnapoli/assembly 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/ */
use function \Assembly\object;
use function \Assembly\get;
class MyModuleDefinitionProvider extend \Assembly\ArrayDefinitionProvider
{
public function getArrayDefinitions()
{
return [
'logger' => object(MyLogger::class),
'logger_alias' => get('logger'),
];
}
}
$provider = new ArrayDefinitionProvider([
// add definitions here
]);
return [
'db.port' => new ParameterDefinition(3306),
];
return [
'logger' => new Reference('monolog'),
];
$definition = new ObjectDefinition('PDO');
$definition->addConstructorArgument('mysql:host=localhost;dbname=test');
$definition->addConstructorArgument('user');
$definition->addConstructorArgument('password');
$definition = new ObjectDefinition('PDO');
$definition->addConstructorArgument(new Reference('db.connection_string'));
$definition->addConstructorArgument('user');
$definition->addConstructorArgument('password');
$definition = new FactoryCallDefinition(new Reference('db.factory'), 'create');
$definition->setArguments(new Reference('db.connection_string'), 'user', 'password');
$definition = new FactoryCallDefinition('Acme\DbFactory', 'create');
// List the definition providers to load
$definitionProviders = [
new Module1DefinitionProvider(),
new Module2DefinitionProvider(),
];
// Define here container entries for the application
$entries = [
'abc' => 'def',
'router' => new Router(...),
];
$container = new Container($entries, $definitionProviders);
$resolver = new \Assembly\Container\DefinitionResolver($container);
$value = $resolver->resolve($definition);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.