Skip to content

Instantly share code, notes, and snippets.

@dg
Created Aug 19, 2014
Embed
What would you like to do?
DI: Symfony versus Nette
services:
newsletter_factory: NewsletterFactory
newsletter_manager: @newsletter_factory::get(@templating)
parameters:
newsletter_manager.class: NewsletterManager
newsletter_factory.class: NewsletterFactory
services:
newsletter_factory:
class: "%newsletter_factory.class%"
newsletter_manager:
class: "%newsletter_manager.class%"
factory_service: newsletter_factory
factory_method: get
arguments:
- "@templating"
@dg
Copy link
Author

dg commented Aug 19, 2014

@gondo
Copy link

gondo commented Mar 2, 2016

you don't have to use parameters in Symfony, that is optional

@Richtermeister
Copy link

Richtermeister commented Mar 2, 2016

That's actually a super-neat syntax. Any downsides? Should be possible to adopt this in Symfony, no? Are there already any efforts on the way?

@theofidry
Copy link

theofidry commented Mar 16, 2016

Let's rectify symfony one:

services:
    newsletter_factory:
        class: NewsletterFactory

    newsletter_manager:
        class: NewsletterManager
        factory: ['@newsletter_factory', get]
        arguments:
            - '@templating'
  • you don't have to use parameters for your classes
  • you're using a deprecated factory declaration

@TomasVotruba
Copy link

TomasVotruba commented Jan 1, 2019

Random visitor passing by in 2019...

# symfony
services:
    App\:
        resource: '../'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment