Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DX] Make debugging typos in tags easier #11511

Closed
wouterj opened this issue Jul 29, 2014 · 5 comments
Closed

[DX] Make debugging typos in tags easier #11511

wouterj opened this issue Jul 29, 2014 · 5 comments
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) FrameworkBundle

Comments

@wouterj
Copy link
Member

wouterj commented Jul 29, 2014

If you are in #symfony on IRC, you can see that at least 10 issues a day are caused by a simple typo. For some places, like _controller, console commands and bundles, exceptions reported by the framework make it very easy to discover these typos.

However, the DependencyInjection tags are one big vague story when you're talking about typos. That's because:

  • Tag name's not validated. If you tag with name: kenrel.event_listener, you get no indication that it is wrong.
  • Tag attributes are not validated. If you tag with evnt: kernel.request, you get no exception.

How can we fix this in a BC way?

Let's discuss that in this issue. A very first shot I think of: You can't. But what we can do is adding validation for the attributes in the compiler passes of the core and also advertising this to other 3th party bundle developers.

Another solution might be to log on the DEBUG level if a tag isn't used in the container during the request. That would help too.

How can we fix this in 3.0

I also think we have to find a fix for this in a non-BC manner. How can we officially integrate better support for tags in the container? Or don't we want to do that?

@fabpot
Copy link
Member

fabpot commented Jul 29, 2014

Validation in core is easy and would catch errors for attributes.

Logging is also a good idea (probably with an error level).

@merk
Copy link
Contributor

merk commented Jul 29, 2014

It might be possible to track any tags that are defined, but never queried during the building phase of the container, and list those in a profiler panel?

@alexandresalome
Copy link

An opt-in option in configuration might make it possible to add it in a "no-BC break" manner?

@linaori
Copy link
Contributor

linaori commented Jul 30, 2014

👍 for the opt-in.

framework:
    compiler:
        validate: [tags, services] # if class exists, there's a PR somewhere regarding this

@cordoval
Copy link
Contributor

I think this could be integrated into symfony http://github.com/matthiasnoback/symfony-service-definition-validator since that already does a lot of checks, this could also be added there?

fabpot added a commit that referenced this issue Sep 28, 2015
This PR was merged into the 2.8 branch.

Discussion
----------

added logging of unused tags

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #11511, #11744
| License       | MIT
| Doc PR        | -

This is the same as #11744 but with some minor tweaks and some unit tests for the compiler pass.

Commits
-------

95c9f50 added some tests
d3271e1 missing tags in whitelist
f51fe4a [FrameworkBundle] [DependencyInjection] added logging of unused tags during container compilation
@fabpot fabpot closed this as completed Sep 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) FrameworkBundle
Projects
None yet
Development

No branches or pull requests

7 participants