8000 bug #19116 [Cache] Fix PdoAdapter examples (HypeMC) · symfony/symfony-docs@c8cdd53 · GitHub
[go: up one dir, main page]

Skip to content

Commit c8cdd53

Browse files
committed
bug #19116 [Cache] Fix PdoAdapter examples (HypeMC)
This PR was merged into the 5.4 branch. Discussion ---------- [Cache] Fix PdoAdapter examples As mentioned in symfony/symfony#52460, using a DSN with the PdoAdapter is currently not supported, instead a service name should be provided, eg: ```yaml app.my_pdo_service: class: \PDO arguments: - 'pgsql:host=localhost' ``` I haven't included the actual service definition since `app.my_psr6_service` isn't included either, but if you think I should, please let me know. Commits ------- 7ab6c81 [Cache] Fix PdoAdapter examples
2 parents ddb9845 + 7ab6c81 commit c8cdd53

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
@@ -143,7 +143,12 @@ Some of these adapters could be configured via shortcuts.
143143
default_psr6_provider: 'app.my_psr6_service'
144144
default_redis_provider: 'redis://localhost'
145145
default_memcached_provider: 'memcached://localhost'
146-
default_pdo_provider: 'pgsql:host=localhost'
146+
default_pdo_provider: 'app.my_pdo_service'
147+
148+
services:
149+
app.my_pdo_service:
150+
class: \PDO
151+
arguments: ['pgsql:host=localhost']
147152
148153
.. code-block:: xml
149154
@@ -164,17 +169,24 @@ Some of these adapters could be configured via shortcuts.
164169
default-psr6-provider="app.my_psr6_service"
165170
default-redis-provider="redis://localhost"
166171
default-memcached-provider="memcached://localhost"
167-
default-pdo-provider="pgsql:host=localhost"
172+
default-pdo-provider="app.my_pdo_service"
168173
/>
169174
</framework:config>
175+
176+
<services>
177+
<service id="app.my_pdo_service" class="\PDO">
178+
<argument>pgsql:host=localhost</argument>
179+
</service>
180+
</services>
170181
</container>
171182
172183
.. code-block:: php
173184
174185
// config/packages/cache.php
186+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
175187
use Symfony\Config\FrameworkConfig;
176188
177-
return static function (FrameworkConfig $framework) {
189+
return static function (FrameworkConfig $framework, ContainerConfigurator $container) {
178190
$framework->cache()
179191
// Only used with cache.adapter.filesystem
180192
->directory('%kernel.cache_dir%/pools')
@@ -183,7 +195,12 @@ Some of these adapters could be configured via shortcuts.
183195
->defaultPsr6Provider('app.my_psr6_service')
184196
->defaultRedisProvider('redis://localhost')
185197
->defaultMemcachedProvider('memcached://localhost')
186-
->defaultPdoProvider('pgsql:host=localhost')
198+
->defaultPdoProvider('app.my_pdo_service')
199+
;
200+
201+
$container->services()
202+
->set('app.my_pdo_service' 537F ;, \PDO::class)
203+
->args(['pgsql:host=localhost'])
187204
;
188205
};
189206

0 commit comments

Comments
 (0)
0