Solved: PHP Fatal Error: Class ‘CLI’ was not found in ‘bin\Magento’ on line 31
Magento2 is full of surprises and I am loving and hating it at the same time. I fix one issue and another issue comes up sooner or later.
Mostly, I have been using Ubuntu for Magento 2 development but I decided to try it on Windows to test the platform performance. Installation was nice and easy and I was able to install demo data without any issue.
After setting up the initial version, I decided to create my own extension which involved a few frontend templating. Everything was normal until I ran ‘php bin\magento setup:di:compile’. Screenshot below.
I was served with a fatal error and after scratching my head a few times – and of course hitting on the wall a few times, I decided to remove var/generation directory. It all went fine this time. Alright, so to cut the long store short, do the following:
STEPS:
- Don’t panic
- Take a deep breath
- Remove {magento_directory}/var/generation/
- Run ‘php bin/magento setup:di:compile’ again
Did it fix your issue? Leave a comment below to let others know :)