Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7d9985c

Browse filesBrowse files
committed
Load services configuration
1 parent 2325ece commit 7d9985c
Copy full SHA for 7d9985c

File tree

1 file changed

+56
-0
lines changed
Filter options

1 file changed

+56
-0
lines changed

‎configuration/micro_kernel_trait.rst

Copy file name to clipboardExpand all lines: configuration/micro_kernel_trait.rst
+56Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ hold the kernel. Now it looks like this::
158158
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
159159
{
160160
$loader->load(__DIR__.'/../config/framework.yaml');
161+
$loader->load(__DIR__.'/../config/services.yaml');
161162

162163
// configure WebProfilerBundle only if the bundle is enabled
163164
if (isset($this->bundles['WebProfilerBundle'])) {
@@ -199,6 +200,61 @@ Before continuing, run this command to add support for the new dependencies:
199200
200201
$ composer require symfony/yaml symfony/twig-bundle symfony/web-profiler-bundle doctrine/annotations
201202
203+
You need add the following service configuration, which is the default config for a new project:
204+
205+
.. configuration-block::
206+
207+
.. code-block:: yaml
208+
209+
# config/services.yaml
210+
services:
211+
# default configuration for services in *this* file
212+
_defaults:
213+
autowire: true # Automatically injects dependencies in your services.
214+
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
215+
216+
# makes classes in src/ available to be used as services
217+
# this creates a service per class whose id is the fully-qualified class name
218+
App\:
219+
resource: '../src/*'
220+
221+
.. code-block:: xml
222+
223+
<!-- config/services.xml -->
224+
<?xml version="1.0" encoding="UTF-8" ?>
225+
<container xmlns="http://symfony.com/schema/dic/services"
226+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
227+
xsi:schemaLocation="http://symfony.com/schema/dic/services
228+
https://symfony.com/schema/dic/services/services-1.0.xsd">
229+
230+
<services>
231+
<!-- Default configuration for services in *this* file -->
232+
<defaults autowire="true" autoconfigure="true"/>
233+
234+
<!-- makes classes in src/ available to be used as services -->
235+
<!-- this creates a service per class whose id is the fully-qualified class name -->
236+
<prototype namespace="App\" resource="../src/*" />
237+
</services>
238+
</container>
239+
240+
.. code-block:: php
241+
242+
// config/services.php
243+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
244+
245+
return function(ContainerConfigurator $configurator) {
246+
// default configuration for services in *this* file
247+
$services = $configurator->services()
248+
->defaults()
249+
->autowire() // Automatically injects dependencies in your services.
250+
->autoconfigure() // Automatically registers your services as commands, event subscribers, etc.
251+
;
252+
253+
// makes classes in src/ available to be used as services
254+
// this creates a service per class whose id is the fully-qualified class name
255+
$services->load('App\\', '../src/*');
256+
};
257+
202258
Unlike the previous kernel, this loads an external ``config/framework.yaml`` file,
203259
because the configuration started to get bigger:
204260

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.