Skip to content

Hopefully improve comments in services.yaml #285

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

Merged
1 commit merged into from
Nov 29, 2017
Merged

Hopefully improve comments in services.yaml #285

1 commit merged into from
Nov 29, 2017

Conversation

nicolas-grekas
Copy link
Member

Q A
License MIT

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

@@ -5,24 +5,23 @@ parameters:
services:
# default configuration for services in *this* file
_defaults:
# automatically injects dependencies in your services
Copy link
Member Author

@nicolas-grekas nicolas-grekas Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current "before the line" comments make the section scary to me
I propose to put these comments at the end of each lines - looks better to the eye IMHO


# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
# you can exclude directories or files
# but if a service is unused, it's removed anyway
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed anymore, esp since service removal is mentioned above now

# controllers are imported separately to make sure they
# have the tag that allows actions to type-hint services
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's explain why this is needed in the first place (ie: only if you do not extend a base controller)

App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']

# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this last note is the most important one, as we've already got several reports from ppl who've got that wrong

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly I don't think this --> "please note that last definitions always replace previous ones" will be enough to understand the problem. The worst thing is that is a tricky problem and not easy to explain: if you define a controller services bellow the App\Controller\ config, it's natural to think that your service will inherit everything from above.

Copy link
Member Author

@nicolas-grekas nicolas-grekas Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's why we absolutely need this line: to hint the user when something doesn't work as one would maybe expect

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include a commented-out example config below?

    # Example: override a service so you can explicitly wire a `$isDebug` constructor arg
    # App\Service\ExampleService
    #     arguments:
    #         $isDebug: '%kernel.debug%'

Copy link
Member Author

@nicolas-grekas nicolas-grekas Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure: we did not add examples for parameters, and I think it was a conscious decision


# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
# you can exclude directories or files
# but if a service is unused, it's removed anyway
exclude: '../src/{DataFixtures,Entity,Migrations,Tests}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove DataFixtures, we just fixed this with DoctrineFixturesBundle 3.0. Woo!

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

@ghost ghost merged commit 4e79628 into symfony:master Nov 29, 2017
ghost pushed a commit that referenced this pull request Nov 29, 2017
@nicolas-grekas nicolas-grekas deleted the app_yaml branch November 29, 2017 18:48
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants