symfonette / neon-integration
Integrates Nette Neon to Symfony
dev-master / 1.0.x-dev
2018-08-30 09:23 UTC
Requires
- php: ^5.5|^7.0
- nette/neon: ^2.2
- symfony/config: ^2.3|^3.0|^4.0
- symfony/dependency-injection: ^2.3|^3.0|^4.0
Requires (Dev)
- fabpot/php-cs-fixer: ^1.11
- nette/di: @dev
- phpunit/phpunit: ^4.8|^5.0
- symfony/expression-language: ^3.0
- symfony/http-kernel: ^3.0
- symfony/var-dumper: ^3.0
Suggests
This package is auto-updated.
Last update: 2024-11-05 04:01:29 UTC
README
Provides integration for Nette Neon with Symfony Dependency Injection component.
Installation
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; // ... }
Usages
Includes
# simplified syntax includes: - parameters.yml # standard YAML syntax imports: - resource: parameters.yml
Services configuration in NEON
Class
# simplified syntax services: mailer: Mailer # standard YAML syntax services: mailer: class: Mailer
Arguments
# simplified syntax services: newsletter_manager: NewsletterManager(@my_mailer) article__manager: class: ArticleManager(@doctrine) # standard YAML syntax services: newsletter_manager: class: NewsletterManager arguments: ['@my_mailer']
Calls
# simplified syntax calls: -
Calls and properties
Factory
# 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')
Autowiring
# 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%]
Alias
# simplified syntax services: translator: @translator_default # standard YAML syntax services: translator: alias: translator_default
Parent
# simplified syntax services: newsletter_manager < mail_manager: NewsletterManager # standard YAML syntax services: newsletter_manager: class: NewsletterManager parent: mail_manager
Expression
# 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()"
Tags
# 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 }
Anonymous services
services: mailer: Mailer(Zend_Mail_Transport_Smtp('smtp.gmail.com'))