I am getting this error on terminal:

PHP Fatal error:  Class 'Cli' not found in /opt/bitnami/apache2/htdocs/bin/magento on line 31

when trying to run these commands:

sudo php bin/magento setup:upgrade
sudo php bin/magento setup:di:compile

Can anyone help?

  • you should run those commands inside your Magento root directory. – fmsthird Mar 20 '19 at 21:35
  • That's where I am running them. – DEVDUDE Mar 20 '19 at 23:53
  • did it happen during the upgrade or compile? – fmsthird Mar 21 '19 at 0:23
  • Both. Anytime I run a command that starts with: sudo php bin/magento – DEVDUDE Mar 21 '19 at 0:32
  • I see. can you try to run composer update first then after, try if commands are working – fmsthird Mar 21 '19 at 0:36

Enter your php path while running bin/magento commands.

sudo /opt/lampp/bin/php bin/magento setup:upgrade
sudo /opt/lampp/bin/php bin/magento setup:di:compile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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