No Commands Defined in the Indexer Namespace – Magento 2 PHP 7.2 (Ubuntu)

indexermagento2

When i want to re Index in Magento2 in php version of 7.3,
this display me this error

An exception was raised while creating "Request"; no instance returned

And when i change to version 7.2
Display this Error…..
enter image description here

Also i use this command with my root Directory (same error)

So how can i simply use Indexer command in Magento2

I thing something too wrong with my Magento 🙁
Also check this image :–
enter image description here

My all commands are not working.
Also i change my Magento Folder Permissions

Best Answer

Please mention your Magento Version first.

An exception was raised while creating "Request"; no instance returned

Your First error is coming due to most likely not changing php version properly, you should only use PHP version 7.2 when you're working on Magento 2.3.x

Change PHP version according to your Magento version, refer below link if you're using Magento 2.3.x

https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html

Try below commands for changing PHP version

sudo a2dismod php7.0
sudo a2enmod php7.2
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php7.2

Also refer this link for similar issue

Magento 2.2 with PHP 7.1.9 Issue

About your second error regarding 7.2 version,

Try to give permission first to your Magento Directory

sudo chmod -R 777 magentoDir

then use your upgrade-deploy commands.

if that doesn't help try to find solution in below link.

https://community.magento.com/t5/Magento-2-x-Admin-Configuration/CLI-not-recognizing-magento-commands/td-p/45869