After upgrading Magento from 2.4.3 to 2.4.4 (or 2.4.5), I cannot run any Magento CLI command. For example, setup upgrade command:
bin/magento setup:upgrade
generates the errors:
Interface "Zend\Stdlib\JsonSerializable" not found#0 /var/www/magento2/vendor/composer/ClassLoader.php(571): include() #1 /var/www/magento2/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile() #2 [internal function]: Composer\Autoload\ClassLoader->loadClass() #3 /var/www/magento2/vendor/magento/framework/ObjectManager/Relations/Runtime.php(38): class_exists() #4 /var/www/magento2/vendor/magento/framework/Interception/Config/Config.php(157): Magento\Framework\ObjectManager\Relations\Runtime->has() #5 /var/www/magento2/vendor/magento/framework/Interception/Config/Config.php(180): Magento\Framework\Interception\Config\Config->_inheritInterception() #6 /var/www/magento2/vendor/magento/framework/Interception/Config/Config.php(213): Magento\Framework\Interception\Config\Config->hasPlugins() #7 /var/www/magento2/vendor/magento/framework/Interception/Config/Config.php(190): Magento\Framework\Interception\Config\Config->generateIntercepted() #8 /var/www/magento2/vendor/magento/framework/Interception/Config/Config.php(122): Magento\Framework\Interception\Config\Config->initializeUncompiled() #9 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(121): Magento\Framework\Interception\Config\Config->__construct() #10 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() #11 /var/www/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() #12 /var/www/magento2/vendor/magento/framework/App/ObjectManager/Environment/Developer.php(84): Magento\Framework\ObjectManager\ObjectManager->get() #13 /var/www/magento2/vendor/magento/framework/App/ObjectManagerFactory.php(191): Magento\Framework\App\ObjectManager\Environment\Developer->configureObjectManager() #14 /var/www/magento2/vendor/magento/framework/App/Bootstrap.php(212): Magento\Framework\App\ObjectManagerFactory->create() #15 /var/www/magento2/vendor/magento/framework/App/Bootstrap.php(127): Magento\Framework\App\Bootstrap->__construct() #16 /var/www/magento2/vendor/magento/framework/Console/Cli.php(185): Magento\Framework\App\Bootstrap::create() #17 /var/www/magento2/vendor/magento/framework/Console/Cli.php(85): Magento\Framework\Console\Cli->initObjectManager() #18 /var/www/magento2/bin/magento(22): Magento\Framework\Console\Cli->__construct() #19 {main}
I tried by removing all cache's, generated codes etc, but I receive always this error. How can I fix it?
I also receive the below error:
bin/magento setup:upgrade
Class 'Zend\Mime\Mime' not found#0 /var/www/magento2/vendor/magento/framework/Code/Generator/EntityAbstract.php(366): ReflectionParameter->getDefaultValue() #1 /var/www/magento2/vendor/magento/framework/Code/Generator/EntityAbstract.php(396): Magento\Framework\Code\Generator\EntityAbstract->extractParameterDefaultValue() #2 [internal function]: Magento\Framework\Code\Generator\EntityAbstract->_getMethodParameterInfo() #3 /var/www/magento2/vendor/magento/framework/Interception/Code/Generator/Interceptor.php(103): array_map() #4 /var/www/magento2/vendor/magento/framework/Interception/Code/Generator/Interceptor.php(76): Magento\Framework\Interception\Code\Generator\Interceptor->_getMethodInfo .... #65 /var/www/magento2/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun() #66 /var/www/magento2/bin/magento(23): Symfony\Component\Console\Application->run() #67 {main}
3 Answers 3
To fix JsonSerializable error, you can implement
\JsonSerializable
instead of
Zend\Stdlib\JsonSerializable
1: Please check the php version first i.e.
php -m
Are you using PHP 8? If not, first, you need to upgrade to PHP 8.
2: Please remove the vendor folder and backup for the safer side. And then run the command: composer install.
3: Install the package again of Zend Framework.
4: Please confirm if mcrypt extension is enabled in PHP.
5: Try running the composer update followed by composer install, this should place JsonSerializable in vendor/zendframework/zend-stdlib/src/JsonSerializable.php.
Thanks
Magento has deprecated the Zend Framework from its codebase.
The Zend classes in the Magento 2 core code have been replaced with the Laminas.
If you are not installed Laminas, install Laminas.
composer require laminas/laminas-serializer
for this issue is fix
Laminas\Stdlib\JsonSerializable
instead of
Zend\Stdlib\JsonSerializable