1. Go to this page and download the library: Download mnapoli/fluent-symfony 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 Fluent\EnableFluentConfig;
use Symfony\Component\HttpKernel\Kernel;
// ...
class AppKernel extends Kernel
{
use EnableFluentConfig;
// ...
}
class AppKernel extends Kernel
{
use EnableFluentConfig;
// ...
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.php');
}
}
# app/config/config.php
return [
// ...
];
return [
'foo' => 'bar',
];
use function Fluent\create;
return [
'mailer' => create(Mailer::class),
];
return [
Mailer::class => create(),
];
use function Fluent\autowire;
return [
Mailer::class => autowire(),
];
use function Fluent\create;
use function Fluent\get;
return [
'newsletter_manager' => create(NewsletterManager::class)
->arguments(get('mailer')->nullIfMissing()),
];
use function Fluent\create;
use function Fluent\get;
return [
'newsletter_manager' => create(NewsletterManager::class)
->method('setMailer', get('mailer')->ignoreIfMissing()),
];
use function Fluent\factory;
return [
'newsletter_manager' => factory([NewsletterManager::class, 'create'], NewsletterManager::class)
->arguments('foo', 'bar'),
];
return [
// you can write:
NewsletterManager::class => factory([NewsletterManager::class, 'create']),
// instead of:
NewsletterManager::class => factory([NewsletterManager::class, 'create'], NewsletterManager::class),
];
use function Fluent\create;
use function Fluent\alias;
return [
'app.phpmailer' => create(PhpMailer::class),
'app.mailer' => alias('app.phpmailer'),
];