Magento 2(cmd)-致命错误:未捕获错误:类';Cli';找不到


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

我刚刚在Windows7(64位)中安装了Magento 2;WAMP(PHP版本7.0.4).

之后,我将尝试使用以下命令清理和刷新缓存。

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

起初,它给了我PHP版本错误,所以我刚刚安装了最新的PHP。php -v返回:

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

现在它在执行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

执行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

有人能帮我解决这个错误吗?

我认为这主要与PHP错误有关,但我无法弄清楚。

使用以下命令检查系统中是否安装了OpenSSL:

dpkg -l | grep -i openssl

如果您使用此命令没有得到任何结果。。这意味着您需要安装OpenSSL。

另一种选择是,您可以在php.ini配置文件中取消注释代码extension=php_openssl.dll

在本地主机的Magento2.1.2中,我也面临着完全相同的问题。

openssl扩展是SSL/TLS保护所必需的,但不可用。

解决方案是通过在php.ini中取消对extension=php_openssl.dll的注释来启用SSL。

我这样做了,并重新启动了XAMPP,但问题仍然存在。

然后在CCD_ 5中,我执行了CCD_。

它从E:/xamp/php/php.ini中给出了Loaded Configuration File。而我的Magento是在D:/xamplep/localhost中。

这意味着,虽然magento安装在D驱动器中,但php.ini是从另一个examplep(E:/xamp/php/php.ini)读取的。

我在E:/xamp/php/php.ini中取消了对extension=php_openssl.dll的评论,我的问题得到了解决。

因此,在php.ini中启用openssl,从中读取所有php设置。要知道该文件在Cli中执行php --ini