Skip to content

Commit ee79074

Browse files
committed
minor #759 Keep the services.yaml file in sync with the default Symfony 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
2 parents de0d0d5 + 3bb3928 commit ee79074

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

config/services.yaml

+13-12
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ parameters:
99
services:
1010
# default configuration for services in *this* file
1111
_defaults:
12-
# automatically injects dependencies in your services
13-
autowire: true
14-
# automatically registers your services as commands, event subscribers, etc.
15-
autoconfigure: true
16-
# this means you cannot fetch services directly from the container via $container->get()
17-
# if you need to do this, you can override this setting on individual services
18-
public: false
19-
# defines the scalar arguments once and apply them to any service defined/created in this file
20-
bind:
12+
autowire: true # Automatically injects dependencies in your services.
13+
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
14+
public: false # Allows optimizing the container by removing unused services; this also means
15+
# fetching services directly from the container via $container->get() won't work.
16+
# The best practice is to be explicit about your dependencies anyway.
17+
bind: # defines the scalar arguments once and apply them to any service defined/created in this file
2118
$locales: '%app_locales%'
2219
$defaultLocale: '%locale%'
2320
$emailSender: '%app.notifications.email_sender%'
@@ -26,9 +23,13 @@ services:
2623
# this creates a service per class whose id is the fully-qualified class name
2724
App\:
2825
resource: '../src/*'
29-
# you can exclude directories or files
30-
# but if a service is unused, it's removed anyway
31-
exclude: '../src/{Entity,Migrations,Tests}'
26+
exclude: '../src/{Entity,Migrations,Tests,Kernel.php}'
27+
28+
# controllers are imported separately to make sure services can be injected
29+
# as action arguments even if you don't extend any base controller class
30+
App\Controller\:
31+
resource: '../src/Controller'
32+
tags: ['controller.service_arguments']
3233

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

0 commit comments

Comments
 (0)