I am working on upgrading PHP 7.4 to 8.1 on my Laminas project.
In config/autoload/global.php I have-
'caches' => require DIR . '/caches.php',
This is caches.php-
'caches' => array(
'memcached' => array(
'adapter' => 'memcache',
'options' => array(
'namespace' => 'IDSSO',
'ttl' => 900, //900 seconds = 15 minutes
),
'plugins' => array(
array(
'name' => 'exception_handler',
'options' => array(
'throw_exceptions' => false,
),
),
)
),
),
);
I go to my portal and I'm seeing this error-
File:
/project/vendor/laminas/laminas-servicemanager/src/ServiceManager.php:620
Message:
Unable to resolve service "memcache" to a factory; are you certain you provided it during configuration?
In my composer.json I added
"laminas/laminas-cache-storage-deprecated-factory" : "^1.0.1",
"laminas/laminas-cache" : "3.4.0"
and module.config.php I added
'service_manager' => array(
'abstract_factories' => array(
'Laminas\Cache\Service\StorageCacheAbstractServiceFactory',
'Laminas\Log\LoggerAbstractServiceFactory',
'Laminas\Cache\Storage\Adapter\Memcache'
),
I wasn't able to resolve this with these changes.
I was able to resolve this myself.
1. I added these packages on composer.json
-
"laminas/laminas-cache-storage-deprecated-factory" : "^1.0.1",
"laminas/laminas-cache-storage-adapter-memcached" : "^2.1.0"
and then did composer update
Alternatively, you can also run-
composer require laminas/laminas-cache-storage-deprecated-factory
and
composer require laminas/laminas-cache-storage-adapter-memcached
instead.
2. Follow the steps from this url- https://github.com/lifenglsf/php_memcached_dll
- copy libmemcached.dll to c:\Windows
- copy php-memcached.dll to you PHP/ext directory
3. On php.ini add this line-
extension=memcached
4. In caches.php file-
Change 'adapter' => 'memcache', to 'adapter' => 'memcached',
Once this is done, do a composer install
, composer update
and restart your local XAMPP.