【问题标题】:PHP Fatal error: Class Bundle\\Controller\\Symfony\\Component\\Intl\\Intl not foundPHP 致命错误:找不到类 Bundle\\Controller\\Symfony\\Component\\Intl\\Intl
【发布时间】:2014-12-27 10:29:00
【问题描述】:

我需要什么

  • 我需要将国家代码转换为货币符号。

     like for USD => $.
    
  • 我需要将货币代码转换为货币符号。

代码

控制器

use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;
class EventDetailController extends Controller
{
          $currency = $data[0]['currency'];
          $Currency= USD

       Symfony\Component\Intl\Intl::getCurrencyBundle()->getCurrencySymbol('USD'); 
}

错误

  PHP Fatal error:  Class 'Acme\\biztradeshowsBundle\\Controller\\Symfony\\Component\\Intl\\Intl' not found in /home/indiamart/public_html/10into/src/Acme/biztradeshowsBundle/Controller/EventDetailController.php on line 180

【问题讨论】:

    标签: php symfony intl


    【解决方案1】:

    你应该写use声明:

    use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;
    use Symfony\Component\Intl\Intl;
    
    class EventDetailController extends Controller
    {
        $currency = $data[0]['currency'];
        $Currency= USD
    
        Intl::getCurrencyBundle()->getCurrencySymbol('USD'); 
    }
    

    或使用前导斜杠编写您的 FQCN:

    use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;
    
    class EventDetailController extends Controller
    {
        $currency = $data[0]['currency'];
        $Currency= USD
    
        \Symfony\Component\Intl\Intl::getCurrencyBundle()->getCurrencySymbol('USD'); 
    }
    

    【讨论】:

    • error PHP 致命错误:在 /home/indiamart/public_html/10into/vendor/symfony/symfony/src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php 中找不到类“ResourceBundle”在第 31 行
    • 这是另一个问题:-) 你可以开始新的话题。但我要问你:你读过symfony.com/doc/current/components/intl.html 吗?您的问题出在 Intl 组件中。也许你没有正确安装 php-intl 扩展。
    • 如何检查 php-intln 是否正确安装
    • 我已经在 bundle 路径是 vendor->symphony->component ->resource bundle->reader->binaybundleraeder 中安装了 intln。
    • 将您自己的表添加到数据库中(如果您需要多个国家/地区)或在您的类中定义数组。
    猜你喜欢
    • 2014-01-06
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-12
    相关资源
    最近更新 更多