8000 Merge branch '5.4' into 6.3 · symfony/symfony-docs@1659563 · GitHub
[go: up one dir, main page]

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 1659563

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: [Cache] Fix PdoAdapter examples
2 parents 6ce583b + c8cdd53 commit 1659563

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

cache.rst

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ Some of these adapters could be configured via shortcuts.
133133
default_psr6_provider: 'app.my_psr6_service'
134134
default_redis_provider: 'redis://localhost'
135135
default_memcached_provider: 'memcached://localhost'
136-
default_pdo_provider: 'pgsql:host=localhost'
136+
default_pdo_provider: 'app.my_pdo_service'
137+
138+
services:
139+
app.my_pdo_service:
140+
class: \PDO
141+
arguments: ['pgsql:host=localhost']
137142
138143
.. code-block:: xml
139144
@@ -154,17 +159,24 @@ Some of these adapters could be configured via shortcuts.
154159
default-psr6-provider="app.my_psr6_service"
155160
default-redis-provider="redis://localhost"
156161
default-memcached-provider="memcached://localhost"
157-
default-pdo-provider="pgsql:host=localhost"
162+
default-pdo-provider="app.my_pdo_service"
158163
/>
159164
</framework:config>
165+
166+
<services>
167+
<service id="app.my_pdo_service" class="\PDO">
168+
<argument>pgsql:host=localhost</argument>
169+
</service>
170+
</services>
160171
</container>
161172
162173
.. code-block:: php
163174
164175
// config/packages/cache.php
176+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
165177
use Symfony\Config\FrameworkConfig;
166178
167-
return static function (FrameworkConfig $framework): void {
179+
return static function (FrameworkConfig $framework, ContainerConfigurator $container): void {
168180
$framework->cache()
169181
// Only used with cache.adapter.filesystem
170182
->directory('%kernel.cache_dir%/pools')
@@ -173,7 +185,12 @@ Some of these adapters could be configured via shortcuts.
173185
->defaultPsr6Provider('app.my_psr6_service')
174186
->defaultRedisProvider('redis://localhost')
175187
->defaultMemcachedProvider('memcached://localhost')
176-
->defaultPdoProvider('pgsql:host=localhost')
188+
->defaultPdoProvider('app.my_pdo_service')
189+
;
190+
191+
$container->services()
192+
->set('app.my_pdo_service', \PDO::class)
193+
->args(['pgsql:host=localhost'])
177194
;
178195
};
179196

0 commit comments

Comments
 (0)
0