Kaushal Suthar
Kaushal Suthar

Reputation: 420

Magento 2 (cmd)- Fatal error: Uncaught Error: Class 'Cli' not found

I've just installed Magento 2 in Windows 7 (64 bit) & WAMP(PHP VER. 7.0.4).

After that I'm trying to clean and flush cache using following commands.

php bin/magento cache:clean
php bin/magento cache:flush 

At first it was giving me that PHP version error, so I've just installed latest PHP. php -v returns:

PHP 7.0.9 (cli) (built: Jul 20 2016 10:47:41) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

Now it's giving me the following error while executing php bin/magento cache:clean

D:\wamp64\www\m2>php bin/magento cache:clean
The openssl extension is required for SSL/TLS protection but is not available. I f you can not enable the openssl extension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true
.... File list
.... File list
.... File list


Fatal error: Uncaught Error: Class 'Cli' not found in D:\wamp64\www\m2\bin\magen
to:31
Stack trace:
#0 {main}
  thrown in D:\wamp64\www\m2\bin\magento on line 31

And the following error while executing php bin/magento cache:flush

The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true.#0 D:\wamp64\www\m2\vendor
\composer\composer\src\Composer\Factory.php(306): Composer\Factory::createRemote
Filesystem(Object(Composer\IO\BufferIO), Object(Composer\Config))
#1 D:\wamp64\www\m2\vendor\composer\composer\src\Composer\Factory.php(532): Comp
oser\Factory->createComposer(Object(Composer\IO\BufferIO), Array, false)
#2 D:\wamp64\www\m2\vendor\magento\framework\Composer\ComposerFactory.php(48): C
omposer\Factory::create(Object(Composer\IO\BufferIO), 'D:\\wamp64\\www\\m...')
#3 D:\wamp64\www\m2\vendor\magento\framework\Composer\ComposerInformation.php(36
2): Magento\Framework\Composer\ComposerFactory->create()
#4 D:\wamp64\www\m2\vendor\magento\framework\Composer\ComposerInformation.php(37
5): Magento\Framework\Composer\ComposerInformation->getComposer()
#5 D:\wamp64\www\m2\vendor\magento\framework\Composer\ComposerInformation.php(24
2): Magento\Framework\Composer\ComposerInformation->getLocker()
#6 D:\wamp64\www\m2\vendor\magento\framework\App\ProductMetadata.php(104): Magen
to\Framework\Composer\ComposerInformation->getSystemPackages()
#7 D:\wamp64\www\m2\vendor\magento\framework\App\ProductMetadata.php(65): Magent
o\Framework\App\ProductMetadata->getSystemPackageVersion()
#8 D:\wamp64\www\m2\vendor\magento\framework\Console\Cli.php(81): Magento\Framew
ork\App\ProductMetadata->getVersion()
#9 D:\wamp64\www\m2\bin\magento(22): Magento\Framework\Console\Cli->__construct(
'Magento CLI')
#10 {main}

Fatal error: Uncaught Error: Class 'Cli' not found in D:\wamp64\www\m2\bin\magen
to:31
Stack trace:
#0 {main}
  thrown in D:\wamp64\www\m2\bin\magento on line 31

Can any one help me solving this error?

I think it is mostly related to the PHP error, but I can't figure it out.

Upvotes: 2

Views: 4948

Answers (2)

Ipsita Rout
Ipsita Rout

Reputation: 5219

I also face this exactly same issue in Magento2.1.2 in my localhost.

The openssl extension is required for SSL/TLS protection but is not available.

The solution is to enable SSL by uncommenting extension=php_openssl.dll in your php.ini.

I did that and restarted my XAMPP, but the issue still persisted.

Then in the Cli I executed php --ini.

It gave Loaded Configuration File from E:/xampp/php/php.ini. Whereas my Magento was in D:/xampp/localhost.

That means, though magento is installed in D drive but the php.ini is read from another xampp(E:/xampp/php/php.ini) in my case.

I un-commented extension=php_openssl.dll in E:/xampp/php/php.ini and my problem get solved.

Hence enable openssl in the php.ini, from where all your php settings are read. To know that file execute php --ini in Cli.

Upvotes: 0

Sanjay Chaudhary
Sanjay Chaudhary

Reputation: 151

Check if OpenSSL is installed in your system using command as follows :

dpkg -l | grep -i openssl

If you don't get anything with this command..that means you need to install OpenSSL.

Another alternative is you can uncomment the code extension=php_openssl.dll in your php.ini configuration file.

Upvotes: 1

Related Questions