【问题标题】:magento setup:upgrade PHP Fatal error: Uncaught Error: Class 'IntlDateFormatter' not foundmagento setup:upgrade PHP Fatal error: Uncaught Error: Class 'IntlDateFormatter' not found
【发布时间】:2020-09-05 18:55:16
【问题描述】:

我在 Mac 上的 Mamp 中安装了 magento 2.3.5-p1。现在我想添加一个模块,但我得到了命令

bin/magento setup:upgrade

错误代码

Running schema recurring...PHP Fatal error:  Uncaught Error: Class 'IntlDateFormatter' not found in /Users/ingokrah/Sites/aquamed/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121 Stack trace: 
#0 /Users/ingokrah/Sites/aquamed/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array) 
#1 /Users/ingokrah/Sites/aquamed/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...') 
#2 /Users/ingokrah/Sites/aquamed/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(167): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...') 
#3 /Users/ingokrah/Sites/aquamed/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(273): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'localeDate', 'Magento\\Framewo...') 
#4 /Users/ingokrah/Sites/aquamed in /Users/ingokrah/Sites/aquamed/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121
{"messages":{"error":[{"code":500,"message":"Server internal error. See details in report api\/365677830219"}]}}%

因为在bash中查询成功,所以安装并激活了扩展php-intl

▶ php -i | grep intl

Configure Command =>  './configure'  '--with-gd' '--with-jpeg-dir=/Applications/MAMP/Library' '--with-png-dir=/Applications/MAMP/Library' '--with-zlib' '--with-zlib-dir=/Applications/MAMP/Library' '--with-freetype-dir=/Applications/MAMP/Library' '--prefix=/Applications/MAMP/bin/php/php7.3.9' '--exec-prefix=/Applications/MAMP/bin/php/php7.3.9' '--sysconfdir=/Applications/MAMP/bin/php/php7.3.9/conf' '--with-config-file-path=/Applications/MAMP/bin/php/php7.3.9/conf' '--enable-ftp' '--with-bz2=/Applications/MAMP/Library' '--with-mysqli=mysqlnd' '--enable-mbstring=all' '--with-curl=/Applications/MAMP/Library' '--enable-sockets' '--enable-bcmath' '--with-imap=shared,/Applications/MAMP/Library/lib/imap-2007f' '--with-imap-ssl=/Applications/MAMP/Library' '--enable-soap' '--with-kerberos' '--enable-calendar' '--with-pgsql=shared,/Applications/MAMP/Library/pg' '--enable-exif' '--with-libxml-dir=/Applications/MAMP/Library' '--with-gettext=shared,/Applications/MAMP/Library' '--with-xsl=/Applications/MAMP/Library' '--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql=shared,/Applications/MAMP/Library/pg' '--with-openssl=/Applications/MAMP/Library' '--enable-zip' '--with-pcre-dir=/Applications/MAMP/Library' '--with-libzip=/Applications/MAMP/Library' '--with-iconv=/Applications/MAMP/Library' '--enable-opcache' '--enable-intl' '--with-tidy=shared' '--with-icu-dir=/Applications/MAMP/Library' '--enable-wddx' '--with-libexpat-dir=/Applications/MAMP/Library' '--with-readline' '--with-mhash' '--with-iconv-dir=/Applications/MAMP/Library' '--with-sodium=/Applications/MAMP/Library' '--with-password-argon2=/Applications/MAMP/Library' '--enable-cgi' '--disable-phpdbg' 'YACC=/Applications/MAMP/Library/bin/bison'
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0

phpinfo 还确认 php-intl 处于活动状态。

错误的根源是什么?

天狼星

【问题讨论】:

  • 我对 Magento 一无所知,如果这是一个愚蠢的问题,非常抱歉,但是...bin/magento 包含什么?它是否偶然有一个到 php 解释器的硬编码路径?
  • php -a 控制台中使用IntlDateFormatter 会发生什么情况?
  • @cyildirim 当我使用外壳时,例如,那没关系php > $DateTime = new DateTime(); php > $IntlDateFormatter = new IntlDateFormatter( php ( 'de_DE', php ( IntlDateFormatter::FULL, php ( IntlDateFormatter::FULL php ( ); php > echo $IntlDateFormatter->format($DateTime); Mittwoch,20. Mai 2020 um 05:50:18 GMT
  • 我建议您重新启动 php-fpm 并清除缓存。我看不出有任何其他原因导致此操作无效。

标签: php magento2 mamp intl


【解决方案1】:

解决方案现在比预期的要容易。 Mamp Apache 服务器和 Macos Apache 服务器之间存在冲突。

虽然export PATH="/Applications/MAMP/bin/php/php7.3.9/bin:$PATH"的路径在.bash_profile文件中是可用的,但是在执行bin/ magento时访问了macos php,并且那里没有启用intl模块。

我重新启动了终端应用程序并运行了source ~/.bash_profile。然后bin/magento setup:upgrade跑成功了

【讨论】:

    【解决方案2】:

    如果您还没有,请切换到开发者模式。

    bin/magento deploy:mode:set developer
    

    清除缓存并清除生成的/文件夹。

    bin/magento cache:flush
    rm -rf generated/*
    

    然后运行bin/magento setup:upgrade

    【讨论】:

    • 我已经清除了缓存和生成的文件夹,但是当我运行bin/magento setup:upgrade 时出现相同的错误消息。在那之前我也重启了apache!
    猜你喜欢
    • 2020-06-28
    • 2020-10-16
    • 1970-01-01
    • 2022-11-09
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多