neclimdul / drupal-psr6
PSR6 wrapper for Drupal Caches.
1.0.0
2026-09-09 20:03 UTC
Requires
- php: >=8.1
- psr/cache: ^3.0.0
Requires (Dev)
- drupal/core: ^10.6.16|^11.4.6|^12.0.0
- php-parallel-lint/php-parallel-lint: ^1.0
- phpstan/phpstan: ^2.2.13
- phpunit/phpunit: ^9.6.36|^10.5.64
- squizlabs/php_codesniffer: ^3.13.6
- symfony/cache-contracts: ^3.7
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This library wraps Drupal's CacheBackends and exposes them as PSR6 CachePools for libraries. This allows to use existing Drupal cache configuration for libraries that expose cache interfaces using PSR6.
Usage
You should be able to create a pool using any cache backend and cache tag invalidator from Drupal's DI Container.
Example using Firebase JWT:
use Drupal\Component\Datetime\Time;
use Drupal\Core\Cache\MemoryBackend;
use NecLimDul\DrupalPsr6\DrupalCacheItemPool;
use Firebase\JWT\CachedKeySet;
use Firebase\JWT\JWT;
// Replace backend and cache validator with real implementations.
$backend = new MemoryBackend(new Time());
$keySet = new CachedKeySet(
'https://example.com/',
new GuzzleHttp\Client(),
new GuzzleHttp\Psr7\HttpFactory(),
new DrupalCacheItemPool(
$this->backend,
$this->backend,
),
);
Help and docs
TODO
Installing Drupal PSR6
You can install using composer.
composer require neclimdul/drupal-psr6