Module (Laminas\Cache\Storage\Adapter\FileSystem) could not be initialized

The issue seems to be with the cache configuration, as the system is unable to initialize the Filesystem cache adapter.

Steps Taken:

  1. I have verified that the laminas/laminas-cache package is installed via Composer.

  2. I have checked the cache configuration and confirmed that the cache_dir option is correctly set to a writable directory.

  3. Permissions for the cache directory have been set correctly.

  4. The relevant module is correctly registered in the module configuration file.

  5. I have cleared the cache and tried reloading the autoload files with no success.

Could you please assist me in troubleshooting this issue or provide guidance on what might be causing the error?

Thank you for your assistance.

Fatal error : Uncaught Laminas\ModuleManager\Exception\RuntimeException: Module (Laminas\Cache\Storage\Adapter\FileSystem) could not be initialized. in /usr/share/nginx/html/vendor/laminas/laminas-modulemanager/src/ModuleManager.php:180 Stack trace: #0 /usr/share/nginx/html/vendor/laminas/laminas-modulemanager/src/ModuleManager.php(154): Laminas\ModuleManager\ModuleManager->loadModuleByName() #1 /usr/share/nginx/html/vendor/laminas/laminas-modulemanager/src/ModuleManager.php(76): Laminas\ModuleManager\ModuleManager->loadModule() #2 /usr/share/nginx/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(318): Laminas\ModuleManager\ModuleManager->onLoadModules() #3 /usr/share/nginx/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(168): Laminas\EventManager\EventManager->triggerListeners() #4 /usr/share/nginx/html/vendor/laminas/laminas-modulemanager/src/ModuleManager.php(99): Laminas\EventManager\EventManager->triggerEvent() #5 /usr/share/nginx/html/vendor/laminas/laminas-mvc/src/Application.php(251): Laminas\ModuleManager\ModuleManager->loadModules() #6 /usr/share/nginx/html/config/container.php(18): Laminas\Mvc\Application::init() #7 /usr/share/nginx/html/public/index.php(39): require(‘…’) #8 {main} thrown in /usr/share/nginx/html/vendor/laminas/laminas-modulemanager/src/ModuleManager.php on line 180

Welcome to the forum :slight_smile:

Do you have the laminas/laminas-component-installer plugin installed?

Please verify that you have installed this package:

Please verify that the entry for it has been added to one of the following files:
/config/application.config.php or
/config/modules.config.php

Also, make sure you are either in development mode or that you have removed the config cache and have run a composer dumpautoload.

Please let us know if any of those suggestions resolves it.

Edit to add: (I somehow missed your Steps Taken section there)

Can you verify that the adapter has actually been installed? That is question number 1 we need to answer. In the latest version of laminas-cache the adapters were moved into their own packages.

Hello @Tyrsson

Follow bellow my composer file:

"require": {
        "php": "^8.3",
        "ext-gd": "*",
        "ext-intl": "*",
        "ext-curl": "*",
        "ext-json": "*",
        "composer-plugin-api": "^2.0",
        "laminas/laminas-component-installer": "^3.4.0",
        "laminas/laminas-mvc": "^3.7.0",
        "laminas/laminas-mvc-form": "^2.1.1",
        "laminas/laminas-mvc-plugins": "1.2.0",
        "laminas/laminas-session": "2.21.0",
        "laminas/laminas-authentication": "^2.17",
        "laminas/laminas-captcha": "^2.17",
        "laminas/laminas-cache": "3.12.0",
        "laminas/laminas-cache-storage-adapter-filesystem": "2.4.*",
        "laminas/laminas-serializer": "^2.17",
        "laminas/laminas-permissions-rbac": "3.6.0",
        "laminas/laminas-router": "^3.13.0",
        "laminas/laminas-i18n": "^2.28",
        "symfony/mailer": "7.1.*",
        "symfony/dotenv": "^7.1.3",
        "mtymek/blast-reflection-factory": "^2.1",
        "league/flysystem": "^3.16",
        "league/flysystem-aws-s3-v3": "3.28.0",
        "firebase/php-jwt": "6.10.1",
        "league/csv": "^9.16.0",
        "maxbanton/cwh" : "1.1.14",
        "aws/aws-sdk-php": "^3.320.2",
        "dompdf/dompdf": "v3.0.0",
        "laminas/laminas-cli": "^1.10",
        "doctrine/doctrine-orm-module": "6.1.0",
        "doctrine/doctrine-laminas-hydrator": "^3.4",
        "doctrine/annotations": "^1.14",
        "laminas/laminas-crypt": "^4.0",
        "laminas/laminas-i18n-resources": "^2.10",
        "laminas/laminas-cache-storage-adapter-memory": "^2.3",
        "doctrine/cache": "^2.2"
    },

The composer dump-autoload was executed but nothing change.

Change development or production mode and nothing change.

Execute this code with docker oficial imagem, copy past from this repository laminas-mvc-skeleton/Dockerfile at 2.5.x · laminas/laminas-mvc-skeleton · GitHub but the error is a same.

There are some additional informations:

  • I’m using laravel herd for my development environment, and there the code works well with no errors;
  • In this project, I`m using a doctrine orm;
  • Permissions was defined chown www-data:www-data -R . | chmod -R 775 .;
  • I create a custom php file and this file I put a raw implementation of laminas cache and file system and works well.
  • Follow bellow my php modules installed:

bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
random
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

I`m try every type of configurations file for cache strategy but not working.

The issue you’re facing is due to case sensitivity in file and class naming, which behaves differently between your local (macOS or Linux with Laravel Herd/Valet) and production environments.

Always treat paths and classnames as they are case sensitive. Always.