Magento 2 – Fix bin/magento No Commands Working – Class ‘Cli’ Not Found Error

clicommand linemagento2

PHP Fatal error: Class 'Cli' not found in
/home/xxx-xxx/public_html/bin/magento on line 31

xxx-xxx@rck:~/public_html$ php bin/magento

No lock file found. Unable to read locked packages#0

/home/xxx/public_html/vendor/composer/composer/src/Composer/Package/Locker.php(146):
Composer\Package\Locker->getLockData()

Magento\Framework\Console\Cli->__construct('Magento CLI')

I am trying following commands:

php bin/magento

php bin/magento setup:upgrade

Best Answer

You are missing the composer.lock file and you must run the commands:

composer update

After you ran the above command, you can run the command:

php bin/magento setup:upgrade