Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

[Doc] Wrong hint about Symfony 3.3 #81

Open
Drachenkaetzchen opened this issue Aug 28, 2017 · 3 comments
Open

[Doc] Wrong hint about Symfony 3.3 #81

Drachenkaetzchen opened this issue Aug 28, 2017 · 3 comments

Comments

@Drachenkaetzchen
Copy link

Drachenkaetzchen commented Aug 28, 2017

The README.md file states:

Note for Symfony >=3.3 users

If you use Symfony at version 3.3 or superior, you do not need to use this bundle
as all the features were ported in Symfony. You can learn more about it in the
Symfony blog or in the Symfony documentation.

However, I find this not to be true. When upgrading to Sf3.3 and removing this bundle, any actions I have defined now stopped working, even with autowiring enabled. The root cause is that no services are passed to the class constructors anymore, whilst with this bundle, they do.

Unfortunately, both the blog and documentation links in that section do not provide information on how to upgrade.

I have 2 questions:

  • Does Sf3.3 completely implement the features of this bundle?
  • If so, what is the upgrade procedure?
@bpolaszek
Copy link
Contributor

Hi @FELICITUS,

SF 3.3 implements autowiring from the work that has been done on DunglasActionBundle. This means it should do exactly what you expect: having services injected into class constructors, without having to define them.

However, DunglasActionBundle was not imported as-is, thus the configuration node dunglas_action in config.yml becomes irrelevant.

To configure which directories should be included or excluded from autowiring, everything is now in your new services.yml.

If you already had a running app under SF <= 3.3 and then upgraded to 3.3, your app/config/services.yml has not been overwritten (of course). When you download or clone a fresh SF 3.3 install, the default app/config/services.yml is now full of comments on how the new DI works.

You should better have a look at The new Symfony 3.3 Service Configuration Changes Explained, which shows a new app/config/services.yml sample.

Personnally, autowiring now totally works on my app without DunglasActionBundle. the most touchy part was about services that are now private by default.

However, I'm poking @dunglas now because there's still something missing in the port: with DunglasActionBundle, one could associate a specific interface or base class to a set of tags:

# app/config/config.yml
dunglas_action:
    directories: ...
    tags:
        'My\Custom\Interface\To\Auto\Tag':
            - 'my_custom.tag'
            - [ 'my_custom.tag_with_attributes', { attribute: 'value' } ]

How can we now achieve this without the bundle? SF docs correctly mention auto-tagging for built-in tags (console.command, kernel.event_subscriber, etc) but nothing for custom ones. Any ideas?

Thanks,
Ben

@dunglas
Copy link
Owner

dunglas commented Oct 2, 2017

@bpolaszek you can use the autoconfigure feature: https://symfony.com/blog/new-in-symfony-3-3-service-autoconfiguration

@bpolaszek
Copy link
Contributor

bpolaszek commented Oct 2, 2017

Magical. Didn't notice the _instanceof part. 🎉 🎊 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants