PHP code example of mtymek / blast-reflection-factory
1. Go to this page and download the library: Download mtymek/blast-reflection-factory 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/ */
mtymek / blast-reflection-factory example snippets
class Mailer
{
public function __construct(MailTransportInterface $transport, MailRenderer $renderer)
{
// ...
}
}
class MailerFactory
{
public function __invoke(ContainerInterface $container)
{
return new Mailer(
$container->get(MailTransportInterface::class),
$container->get(MailRenderer::class)
);
}
}
use Blast\ReflectionFactory\ReflectionFactory;
return [
'dependencies' => [
'factories' => [
// use normal factory for classes that Renderer::class => ReflectionFactory::class,
Mailer::class => ReflectionFactory::class,
],
'aliases' => [
MailTransportInterface::class => SmtpMailTransport::class,
],
]
];