Skip to content

Commit

Permalink
minor symfony#19416 [Cache] Document using DSN with PDOAdapter (HypeMC)
Browse files Browse the repository at this point in the history
This PR was merged into the 7.1 branch.

Discussion
----------

[Cache] Document using DSN with PDOAdapter

Fix symfony#19415.

Commits
-------

1bd5535 [Cache] Document using DSN with PDOAdapter
  • Loading branch information
javiereguiluz committed Jan 13, 2024
2 parents d52f563 + 1bd5535 commit d82fae0
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,7 @@ Some of these adapters could be configured via shortcuts.
default_psr6_provider: 'app.my_psr6_service'
default_redis_provider: 'redis://localhost'
default_memcached_provider: 'memcached://localhost'
default_pdo_provider: 'app.my_pdo_service'
services:
app.my_pdo_service:
class: \PDO
arguments: ['pgsql:host=localhost']
default_pdo_provider: 'pgsql:host=localhost'
.. code-block:: xml
Expand All @@ -159,24 +154,17 @@ Some of these adapters could be configured via shortcuts.
default-psr6-provider="app.my_psr6_service"
default-redis-provider="redis://localhost"
default-memcached-provider="memcached://localhost"
default-pdo-provider="app.my_pdo_service"
default-pdo-provider="pgsql:host=localhost"
/>
</framework:config>
<services>
<service id="app.my_pdo_service" class="\PDO">
<argument>pgsql:host=localhost</argument>
</service>
</services>
</container>
.. code-block:: php
// config/packages/cache.php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Config\FrameworkConfig;
return static function (FrameworkConfig $framework, ContainerConfigurator $container): void {
return static function (FrameworkConfig $framework): void {
$framework->cache()
// Only used with cache.adapter.filesystem
->directory('%kernel.cache_dir%/pools')
Expand All @@ -185,15 +173,14 @@ Some of these adapters could be configured via shortcuts.
->defaultPsr6Provider('app.my_psr6_service')
->defaultRedisProvider('redis://localhost')
->defaultMemcachedProvider('memcached://localhost')
->defaultPdoProvider('app.my_pdo_service')
;
$container->services()
->set('app.my_pdo_service', \PDO::class)
->args(['pgsql:host=localhost'])
->defaultPdoProvider('pgsql:host=localhost')
;
};
.. versionadded:: 7.1

Using a DSN as the provider for the PDO adapter was introduced in Symfony 7.1.

.. _cache-create-pools:

Creating Custom (Namespaced) Pools
Expand Down

0 comments on commit d82fae0

Please sign in to comment.