Skip to content

Commit f9af238

Browse files
committed
Minor fixes in configuration blocks
1 parent 3e717fc commit f9af238

19 files changed

+530
-225
lines changed

bundles/configuration.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,9 @@ Assuming the XSD file is called ``hello-1.0.xsd``, the schema location will be
429429
<container xmlns="http://symfony.com/schema/dic/services"
430430
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
431431
xmlns:acme-hello="http://acme_company.com/schema/dic/hello"
432-
xsi:schemaLocation="http://acme_company.com/schema/dic/hello
432+
xsi:schemaLocation="http://symfony.com/schema/dic/services
433+
https://symfony.com/schema/dic/services/services-1.0.xsd
434+
http://acme_company.com/schema/dic/hello
433435
https://acme_company.com/schema/dic/hello/hello-1.0.xsd">
434436
435437
<acme-hello:config>

bundles/prepend_extension.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,14 @@ The above would be the equivalent of writing the following into the
122122
xmlns:acme-something="http://example.org/schema/dic/acme_something"
123123
xmlns:acme-other="http://example.org/schema/dic/acme_other"
124124
xsi:schemaLocation="http://symfony.com/schema/dic/services
125-
https://symfony.com/schema/dic/services/services-1.0.xsd">
125+
https://symfony.com/schema/dic/services/services-1.0.xsd
126+
http://example.org/schema/dic/acme_something
127+
https://example.org/schema/dic/acme_something/acme_something-1.0.xsd
128+
http://example.org/schema/dic/acme_other
129+
https://example.org/schema/dic/acme_something/acme_other-1.0.xsd">
126130
127131
<acme-something:config use-acme-goodbye="false">
132+
<!-- ... -->
128133
<acme-something:entity-manager-name>non_default</acme-something:entity-manager-name>
129134
</acme-something:config>
130135

cache.rst

+32-10
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
6565
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6666
xmlns:framework="http://symfony.com/schema/dic/symfony"
6767
xsi:schemaLocation="http://symfony.com/schema/dic/services
68-
https://symfony.com/schema/dic/services/services-1.0.xsd">
68+
https://symfony.com/schema/dic/services/services-1.0.xsd
69+
http://symfony.com/schema/dic/symfony
70+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
6971
7072
<framework:config>
7173
<framework:cache app="cache.adapter.filesystem"
@@ -133,7 +135,9 @@ will create pool with service id of ``cache.[type]``
133135
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
134136
xmlns:framework="http://symfony.com/schema/dic/symfony"
135137
xsi:schemaLocation="http://symfony.com/schema/dic/services
136-
https://symfony.com/schema/dic/services/services-1.0.xsd">
138+
https://symfony.com/schema/dic/services/services-1.0.xsd
139+
http://symfony.com/schema/dic/symfony
140+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
137141
138142
<framework:config>
139143
<!--
@@ -143,6 +147,7 @@ will create pool with service id of ``cache.[type]``
143147
default_memcached_provider: Service: cache.memcached
144148
default_pdo_provider: Service: cache.pdo
145149
-->
150+
<!-- "directory" attribute is only used with cache.adapter.filesystem -->
146151
<framework:cache directory="%kernel.cache_dir%/pools"
147152
default_doctrine_provider="app.doctrine_cache"
148153
default_psr6_provider="app.my_psr6_service"
@@ -204,7 +209,9 @@ You can also create more customized pools. All you need is an adapter:
204209
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
205210
xmlns:framework="http://symfony.com/schema/dic/symfony"
206211
xsi:schemaLocation="http://symfony.com/schema/dic/services
207-
https://symfony.com/schema/dic/services/services-1.0.xsd">
212+
https://symfony.com/schema/dic/services/services-1.0.xsd
213+
http://symfony.com/schema/dic/symfony
214+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
208215
209216
<framework:config>
210217
<framework:cache default_memcached_provider="memcached://localhost">
@@ -276,7 +283,9 @@ For advanced configurations it could sometimes be useful to use a pool as an ada
276283
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
277284
xmlns:framework="http://symfony.com/schema/dic/symfony"
278285
xsi:schemaLocation="http://symfony.com/schema/dic/services
279-
https://symfony.com/schema/dic/services/services-1.0.xsd">
286+
https://symfony.com/schema/dic/services/services-1.0.xsd
287+
http://symfony.com/schema/dic/symfony
288+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
280289
281290
<framework:config>
282291
<framework:cache app="my_cache_pool">
@@ -354,7 +363,9 @@ and use that when configuring the pool.
354363
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
355364
xmlns:framework="http://symfony.com/schema/dic/symfony"
356365
xsi:schemaLocation="http://symfony.com/schema/dic/services
357-
https://symfony.com/schema/dic/services/services-1.0.xsd">
366+
https://symfony.com/schema/dic/services/services-1.0.xsd
367+
http://symfony.com/schema/dic/symfony
368+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
358369
359370
<framework:config>
360371
<framework:cache>
@@ -364,6 +375,7 @@ and use that when configuring the pool.
364375
365376
<services>
366377
<service id="app.my_custom_redis_provider" class="\Redis">
378+
<factory class="Symfony\Component\Cache\Adapter\RedisAdapter" method="createConnection"/>
367379
<argument>redis://localhost</argument>
368380
<argument type="collection">
369381
<argument key="retry_interval">2</argument>
@@ -376,6 +388,8 @@ and use that when configuring the pool.
376388
.. code-block:: php
377389
378390
// app/config/config.php
391+
use Symfony\Component\Cache\Adapter\RedisAdapter;
392+
379393
$container->loadFromExtension('framework', [
380394
'cache' => [
381395
'pools' => [
@@ -387,12 +401,14 @@ and use that when configuring the pool.
387401
],
388402
]);
389403
390-
$container->getDefinition('app.my_custom_redis_provider', \Redis::class)
404+
$container->register('app.my_custom_redis_provider', \Redis::class)
405+
->setFactory([RedisAdapter::class, 'createConnection'])
391406
->addArgument('redis://localhost')
392407
->addArgument([
393408
'retry_interval' => 2,
394409
'timeout' => 10
395-
]);
410+
])
411+
;
396412
397413
Creating a Cache Chain
398414
----------------------
@@ -448,7 +464,9 @@ Symfony stores the item automatically in all the missing pools.
448464
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
449465
xmlns:framework="http://symfony.com/schema/dic/symfony"
450466
xsi:schemaLocation="http://symfony.com/schema/dic/services
451-
https://symfony.com/schema/dic/services/services-1.0.xsd">
467+
https://symfony.com/schema/dic/services/services-1.0.xsd
468+
http://symfony.com/schema/dic/symfony
469+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
452470
453471
<framework:config>
454472
<framework:cache>
@@ -474,6 +492,9 @@ Symfony stores the item automatically in all the missing pools.
474492
.. code-block:: php
475493
476494
// app/config/config.php
495+
use Symfony\Component\Cache\Adapter\ChainAdapter;
496+
use Symfony\Component\DependencyInjection\Reference;
497+
477498
$container->loadFromExtension('framework', [
478499
'cache' => [
479500
'pools' => [
@@ -495,13 +516,14 @@ Symfony stores the item automatically in all the missing pools.
495516
],
496517
]);
497518
498-
$container->getDefinition('app.my_cache_chain_adapter', \Symfony\Component\Cache\Adapter\ChainAdapter::class)
519+
$container->register('app.my_cache_chain_adapter', ChainAdapter::class)
499520
->addArgument([
500521
new Reference('cache.array'),
501522
new Reference('cache.apcu'),
502523
new Reference('cache.my_redis'),
503524
])
504-
->addArgument(31536000);
525+
->addArgument(31536000)
526+
;
505527
506528
.. note::
507529

configuration.rst

+2-8
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ The main configuration file is called ``config.yml``:
8484
8585
// Twig Configuration
8686
$container->loadFromExtension('twig', [
87-
'debug' => '%kernel.debug%',
87+
'debug' => '%kernel.debug%',
8888
'strict_variables' => '%kernel.debug%',
8989
]);
9090
@@ -196,14 +196,8 @@ can also load XML files or PHP files.
196196
<?xml version="1.0" encoding="UTF-8" ?>
197197
<container xmlns="http://symfony.com/schema/dic/services"
198198
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
199-
xmlns:framework="http://symfony.com/schema/dic/symfony"
200-
xmlns:twig="http://symfony.com/schema/dic/twig"
201199
xsi:schemaLocation="http://symfony.com/schema/dic/services
202-
https://symfony.com/schema/dic/services/services-1.0.xsd
203-
http://symfony.com/schema/dic/symfony
204-
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd
205-
http://symfony.com/schema/dic/twig
206-
https://symfony.com/schema/dic/twig/twig-1.0.xsd">
200+
https://symfony.com/schema/dic/services/services-1.0.xsd">
207201
208202
<imports>
209203
<import resource="parameters.res" type="yml"/>

configuration/environments.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ this code and changing the environment string.
231231
232232
<doctrine:dbal logging="%kernel.debug%"/>
233233
234+
<!-- ... ->
234235
</container>
235236
236237
.. code-block:: php
@@ -240,7 +241,6 @@ this code and changing the environment string.
240241
'logging' => '%kernel.debug%',
241242
// ...
242243
],
243-
// ...
244244
]);
245245
246246
Selecting the Environment for Console Commands

configuration/external_parameters.rst

+35-24
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ variable in your service container configuration, you can reference it using
4747
https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
4848
4949
<doctrine:config>
50-
<doctrine:dbal
51-
host="%env(DATABASE_HOST)%"
52-
/>
50+
<doctrine:dbal host="%env(DATABASE_HOST)%"/>
5351
</doctrine:config>
5452
5553
</container>
@@ -81,7 +79,8 @@ will be used whenever the corresponding environment variable is *not* found:
8179
<?xml version="1.0" encoding="UTF-8" ?>
8280
<container xmlns="http://symfony.com/schema/dic/services"
8381
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
84-
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
82+
xsi:schemaLocation="http://symfony.com/schema/dic/services
83+
https://symfony.com/schema/dic/services/services-1.0.xsd">
8584
8685
<parameters>
8786
<parameter key="database_host">%env(DATABASE_HOST)%</parameter>
@@ -160,7 +159,7 @@ turn the value of the ``HTTP_PORT`` env var into an integer:
160159
# app/config/config.yml
161160
framework:
162161
router:
163-
http_port: env(int:HTTP_PORT)
162+
http_port: '%env(int:HTTP_PORT)%'
164163
165164
.. code-block:: xml
166165
@@ -379,7 +378,7 @@ Symfony provides the following env var processors:
379378
parameters:
380379
env(HOST): '10.0.0.1'
381380
sentry_host: '%env(HOST)%'
382-
env(SENTRY_DSN): 'http://%sentry_host%/project'
381+
env(SENTRY_DSN): 'https://%sentry_host%/project'
383382
sentry:
384383
dsn: '%env(resolve:SENTRY_DSN)%'
385384
@@ -388,14 +387,15 @@ Symfony provides the following env var processors:
388387
<!-- app/config/config.xml -->
389388
<?xml version="1.0" encoding="UTF-8" ?>
390389
<container xmlns="http://symfony.com/schema/dic/services"
390+
xmlns:sentry="http://symfony.com/schema/dic/sentry"
391391
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
392392
xsi:schemaLocation="http://symfony.com/schema/dic/services
393393
https://symfony.com/schema/dic/services/services-1.0.xsd">
394394
395395
<parameters>
396396
<parameter key="env(HOST)">10.0.0.1</parameter>
397397
<parameter key="sentry_host">%env(HOST)%</parameter>
398-
<parameter key="env(SENTRY_DSN)">http://%sentry_host%/project</parameter>
398+
<parameter key="env(SENTRY_DSN)">https://%sentry_host%/project</parameter>
399399
</parameters>
400400
401401
<sentry:config dsn="%env(resolve:SENTRY_DSN)%"/>
@@ -406,7 +406,7 @@ Symfony provides the following env var processors:
406406
// app/config/config.php
407407
$container->setParameter('env(HOST)', '10.0.0.1');
408408
$container->setParameter('sentry_host', '%env(HOST)%');
409-
$container->setParameter('env(SENTRY_DSN)', 'http://%sentry_host%/project');
409+
$container->setParameter('env(SENTRY_DSN)', 'https://%sentry_host%/project');
410410
$container->loadFromExtension('sentry', [
411411
'dsn' => '%env(resolve:SENTRY_DSN)%',
412412
]);
@@ -420,49 +420,59 @@ Symfony provides the following env var processors:
420420
421421
# app/config/config.yml
422422
parameters:
423-
env(AUTH_FILE): '../config/auth.json'
424-
google:
425-
auth: '%env(file:AUTH_FILE)%'
423+
env(AUTH_FILE): '../auth.json'
424+
425+
services:
426+
some_authenticator:
427+
arguments:
428+
$auth: '%env(file:AUTH_FILE)%'
426429
427430
.. code-block:: xml
428431
429432
<!-- app/config/config.xml -->
430433
<?xml version="1.0" encoding="UTF-8" ?>
431434
<container xmlns="http://symfony.com/schema/dic/services"
432435
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
433-
xmlns:framework="http://symfony.com/schema/dic/symfony"
434436
xsi:schemaLocation="http://symfony.com/schema/dic/services
435437
https://symfony.com/schema/dic/services/services-1.0.xsd
436438
http://symfony.com/schema/dic/symfony
437439
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
438440
439441
<parameters>
440-
<parameter key="env(AUTH_FILE)">../config/auth.json</parameter>
442+
<parameter key="env(AUTH_FILE)">../auth.json</parameter>
441443
</parameters>
442444
443-
<google auth="%env(file:AUTH_FILE)%"/>
445+
<services>
446+
<service id="some_authenticator">
447+
<argument key="$auth">"%env(file:AUTH_FILE)%"<argument/>
448+
<service>
449+
</services>
444450
</container>
445451
446452
.. code-block:: php
447453
448454
// app/config/config.php
449-
$container->setParameter('env(AUTH_FILE)', '../config/auth.json');
450-
$container->loadFromExtension('google', [
451-
'auth' => '%env(file:AUTH_FILE)%',
452-
]);
455+
$container->setParameter('env(AUTH_FILE)', __DIR__.'/../auth.json');
456+
457+
$container->register('some_authenticator')
458+
->setArgument('$auth', '%env(file:AUTH_FILE)%')
459+
;
453460
454461
It is also possible to combine any number of processors:
455462

456463
.. code-block:: yaml
457464
458465
parameters:
459466
env(AUTH_FILE): "%kernel.project_dir%/config/auth.json"
460-
google:
461-
# 1. gets the value of the AUTH_FILE env var
462-
# 2. replaces the values of any config param to get the config path
463-
# 3. gets the content of the file stored in that path
464-
# 4. JSON-decodes the content of the file and returns it
465-
auth: '%env(json:file:resolve:AUTH_FILE)%'
467+
468+
services:
469+
some_authenticator:
470+
arguments:
471+
# 1. gets the value of the AUTH_FILE env var
472+
# 2. replaces the values of any config param to get the config path
473+
# 3. gets the content of the file stored in that path
474+
# 4. JSON-decodes the content of the file and returns it
475+
$auth: '%env(json:file:resolve:AUTH_FILE)%'
466476
467477
Custom Environment Variable Processors
468478
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -550,3 +560,4 @@ the Symfony service container::
550560
// app/config/parameters.php
551561
include_once('/path/to/drupal/sites/default/settings.php');
552562
$container->setParameter('drupal.database.url', $db_url);
563+

configuration/using_parameters_in_dic.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ Now, examine the results to see this closely:
5151
5252
<?xml version="1.0" encoding="UTF-8" ?>
5353
<container xmlns="http://symfony.com/schema/dic/services"
54-
xmlns:my-bundle="http://example.org/schema/dic/my_bundle">
54+
xmlns:my-bundle="http://example.org/schema/dic/my_bundle"
55+
xsi:schemaLocation="http://symfony.com/schema/dic/services
56+
https://symfony.com/schema/dic/services/services-1.0.xsd
57+
http://example.org/schema/dic/my_bundle
58+
https://example.org/schema/dic/my_bundle/my_bundle-1.0.xsd">
5559
5660
<my-bundle:config logging="true"/>
5761
<!-- true, as expected -->

console/commands_as_services.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,22 @@ Or set the ``command`` attribute on the ``console.command`` tag in your service
9696
.. code-block:: yaml
9797
9898
services:
99+
# ...
99100
100101
AppBundle\Command\SunshineCommand:
101102
tags:
102103
- { name: 'console.command', command: 'app:sunshine' }
103-
# ...
104104
105105
.. code-block:: xml
106106
107107
<?xml version="1.0" encoding="UTF-8" ?>
108108
<container xmlns="http://symfony.com/schema/dic/services"
109109
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
110-
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
110+
xsi:schemaLocation="http://symfony.com/schema/dic/services
111+
https://symfony.com/schema/dic/services/services-1.0.xsd">
111112
112113
<services>
114+
<!-- ... -->
113115
114116
<service id="AppBundle\Command\SunshineCommand">
115117
<tag name="console.command" command="app:sunshine"/>
@@ -124,8 +126,7 @@ Or set the ``command`` attribute on the ``console.command`` tag in your service
124126
125127
// ...
126128
127-
$container
128-
->register(SunshineCommand::class)
129+
$container->register(SunshineCommand::class)
129130
->addTag('console.command', ['command' => 'app:sunshine'])
130131
;
131132

0 commit comments

Comments
 (0)