i have tried to run magento upgrade and deploy and flush command i am getting the below error. https://i.imgur.com/gcMP1m1.png

Fatal error: Uncaught TypeError: Argument 1 passed to Zend\ServiceManager\ServiceManager::has() must be of the type string, array given, called in /home/public_html/vendor/zendframework/zend-servicemanager/src/ServiceManager.php on line 283 and defined in /home/public_html/vendor/zendframework/zend-servicemanager/src/ServiceManager.php:695
Stack trace:
#0 /home/public_html/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(283): Zend\ServiceManager\ServiceManager->has(Array, false)
#1 /home/public_html/vendor/zendframework/zend-servicemanager/src/Config.php(133): Zend\ServiceManager\ServiceManager->setFactory('EventManager', 'Zend\\Mvc\\Servic...')
#2 /home/public_html/vendor/zendframework/zend-mvc/src/Service/ServiceManagerConfig.php(238): Zend\ServiceManager\Config->configureServiceManager(Object(Zend\ServiceManager\ServiceManager))
#3 /home/public_html/setup/src/Magento/Setup/Application.php(32): Zend\Mvc\Service\ServiceMan in /home/public_html/vendor/zendframework/zend-servicemanager/src/ServiceManager.php on line 695
  • Should check your php version as well. Commented May 26, 2023 at 3:37

2 Answers 2


Try this all step it will be useful for you

1.Clear the generated files: Run the following command from your Magento root directory to clean up the generated files.

php bin/magento setup:di:compile
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f

2.Flush the cache: Run the following command to clear the cache.

php bin/magento cache:flush

3.Remove generated directories: Delete the contents of the generated and var/cache directories. You can do this manually or by running the following commands.

  rm -rf generated/*
  rm -rf var/cache/*

4.Check for conflicting modules: Ensure that there are no conflicting modules or extensions installed. Disable any recently installed or updated extensions and check if the error persists.

5.Update dependencies: Make sure your Magento installation has all the required dependencies and they are up to date

Run the following command to update the dependencies:

  composer update

6.Verify PHP version and extensions: Confirm that your PHP version is compatible with Magento 2.4.2

7.Check file permissions: Ensure that the file permissions are set correctly for your Magento installation.

8.Check for custom code or overrides: If you have custom code or overrides in your project, review them for any potential conflicts or errors.

If the above steps don't resolve the issue, please provide more details about your Magento setup, including any customizations or extensions you have installed.

  • I have tried to clear cache and remove generated directory still i am getting same issue.even not running compile command and any other commands Commented May 25, 2023 at 13:35
  • I'm also faced this problem and im use this commands only clear that error let im searching other if im got somethink i will post thank you....
    – Ansari
    Commented May 25, 2023 at 13:42

Try deleting the vendor directory using the command rm -rf ./vendor, then run composer install, and finally, attempt to follow the advice provided in the previous answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.