【问题标题】:Magento 2 (cmd)- Fatal error: Uncaught Error: Class 'Cli' not foundMagento 2 (cmd) - 致命错误:未捕获的错误:未找到“Cli”类
【发布时间】:2016-07-29 23:28:29
【问题描述】:

我刚刚在 Windows 7(64 位)和 WAMP(PHP VER. 7.0.4)中安装了 Magento 2。

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

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错误有关,但我无法弄清楚。

【问题讨论】:

    标签: php magento2


    【解决方案1】:

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

    dpkg -l | grep -i openssl
    

    如果你没有用这个命令得到任何东西..那意味着你需要安装 OpenSSL。

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

    【讨论】:

      【解决方案2】:

      我在本地主机的 Magento2.1.2 中也遇到了同样的问题。

      SSL/TLS 保护需要 openssl 扩展,但不可用。

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

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

      然后在Cli我执行php --ini

      它给了来自 E:/xampp/php/php.ini 的 Loaded Configuration File。而我的 Magento 位于 D:/xampp/localhost。

      这意味着,虽然 magento 安装在 D 盘,但在我的情况下,php.ini 是从另一个 xampp(E:/xampp/php/php.ini) 读取的。

      我在 E:/xampp/php/php.ini 中取消了 extension=php_openssl.dll 的注释,我的问题得到了解决。

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

      【讨论】:

        猜你喜欢
        • 2018-09-06
        • 2021-07-10
        • 1970-01-01
        • 1970-01-01
        • 2018-01-01
        • 1970-01-01
        • 2023-03-25
        • 2020-09-03
        • 1970-01-01
        相关资源
        最近更新 更多