Skip to content

Commit

Permalink
minor #759 Keep the services.yaml file in sync with the default Symfo…
Browse files Browse the repository at this point in the history
…ny file (javiereguiluz)

This PR was merged into the master branch.

Discussion
----------

Keep the services.yaml file in sync with the default Symfony file

In this demo app we always keep config files in sync with those provided by the Symfony recipes. This makes the config easier to understand for newcomers (there will be no surprises because when they install Symfony, they'll get the same config they saw on this app).

In addition, I think it's a good idea to keep the `App\Controller\` config. It's true that technically we don't need it because our controllers extend from the base controller. But having this config explicitly, makes it easier to understand what's going on with the services created from controllers.

Commits
-------

3bb3928 Keep the services.yaml file in sync with the default Symfony file
  • Loading branch information
javiereguiluz committed Feb 4, 2018
2 parents de0d0d5 + 3bb3928 commit ee79074
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions config/services.yaml
Expand Up @@ -9,15 +9,12 @@ parameters:
services:
# default configuration for services in *this* file
_defaults:
# automatically injects dependencies in your services
autowire: true
# automatically registers your services as commands, event subscribers, etc.
autoconfigure: true
# this means you cannot fetch services directly from the container via $container->get()
# if you need to do this, you can override this setting on individual services
public: false
# defines the scalar arguments once and apply them to any service defined/created in this file
bind:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
bind: # defines the scalar arguments once and apply them to any service defined/created in this file
$locales: '%app_locales%'
$defaultLocale: '%locale%'
$emailSender: '%app.notifications.email_sender%'
Expand All @@ -26,9 +23,13 @@ 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/{Entity,Migrations,Tests}'
exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'

# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']

# when the service definition only contains arguments, you can omit the
# 'arguments' key and define the arguments just below the service class
Expand Down

0 comments on commit ee79074

Please sign in to comment.