Provides integration for Nette Neon with Symfony Dependency Injection component.
With composer:
composer require symfonette/neon-integration
You can use it with Dependency Injection component:
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfonette\NeonIntegration\DependencyInjection\NeonFileLoader;
$container = new ContainerBuilder();
$loader = new NeonFileLoader($container);
$loader->load('/path/to/config.neon');
If you are using Symfony framework you can update your app/AppKernel.php
file:
use Symfony\Component\HttpKernel\Kernel;
use Symfonette\NeonIntegration\HttpKernel\NeonContainerLoaderTrait;
class AppKernel extends Kernel
{
use NeonContainerLoaderTrait;
// ...
}
# simplified syntax
includes:
- parameters.yml
# standard YAML syntax
imports:
- resource: parameters.yml
# simplified syntax
services:
mailer: Mailer
# standard YAML syntax
services:
mailer:
class: Mailer
# simplified syntax
services:
newsletter_manager: NewsletterManager(@my_mailer)
article__manager:
class: ArticleManager(@doctrine)
# standard YAML syntax
services:
newsletter_manager:
class: NewsletterManager
arguments: ['@my_mailer']
# simplified syntax
calls:
-
# simplified syntax
services:
form:
class: App\Form
factory: App\FormFactory::createForm('registration')
# standard YAML syntax
services:
form:
class: App\Form
factory: App\FormFactory::createForm('registration')
# simplified syntax
services:
twitter_client: AppBundle\TwitterClient(...)
facebook_client: AppBundle\FacebookClient(..., %kernel.root_dir%)
# standard YAML syntax
services:
twitter_client:
class: "AppBundle\TwitterClient"
autowire: true
facebook_client:
class: "AppBundle\FacebookClient"
autowire: true
arguments: ['', %kernel.root_dir%]
# simplified syntax
services:
translator: @translator_default
# standard YAML syntax
services:
translator:
alias: translator_default
# simplified syntax
services:
newsletter_manager < mail_manager: NewsletterManager
# standard YAML syntax
services:
newsletter_manager:
class: NewsletterManager
parent: mail_manager
# alternative syntax
services:
my_mailer:
class: Acme\HelloBundle\Mailer
arguments:
- expr("service('mailer_configuration').getMailerMethod()")
#- expression("service('mailer_configuration').getMailerMethod()")
# standard YAML syntax
services:
my_mailer:
class: Acme\HelloBundle\Mailer
arguments:
- "@=service('mailer_configuration').getMailerMethod()"
# symplified syntax
services:
app.response_listener:
class: ResponseListener
tags:
- kernel.event_listener(event=kernel.response, method=onKernelResponse)
captcha:
class: CaptchaType
tags:
- form.type
# standard YAML syntax
services:
app.response_listener:
class: ResponseListener
tags:
- { name: kernel.event_listener, event: kernel.response, method: onKernelResponse }
captcha:
class: CaptchaType
tags:
- { name: form.type }
services:
mailer: Mailer(Zend_Mail_Transport_Smtp('smtp.gmail.com'))