1. Go to this page and download the library: Download contenir/cache-laminas-mvc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
contenir / cache-laminas-mvc example snippets
// config/autoload/pagecache.global.php
use Contenir\Cache\Laminas\Mvc\Listener\CacheStrategy;
return [
'pagecache' => [
// Service ID resolving to a Laminas\Cache\Storage\StorageInterface.
'cache' => 'cache.pagecache',
// Default per-request options. The `cache` flag is the master
// enable switch — admin's pagecache.local.php overrides it
// without touching siblings.
'options' => [
'cache' => true,
'cache_with_query' => true,
'cache_with_session' => false,
'ttl' => 600,
],
// Optional regex => options-overrides.
'routes' => [
'/api.*' => ['cache' => false],
],
],
// Shared-event-manager attachments. The keys are SharedEventManager
// identifiers (typically Application::class); the values are
// event-name => priority pairs. Event names map to listener methods
// via `'on' . ucwords($event)` — so 'dispatch' → onDispatch,
// 'finish' → onFinish.
'events' => [
CacheStrategy::class => [
\Laminas\Mvc\Application::class => [
'dispatch' => -100,
'finish' => 100,
],
],
],
];