-1

What I Need

  • i Need To convert country code to currency Symbol.

     like for USD => $.
    
  • i Need to convert Currency code to currency symbol.

Code

controller

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 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
user2818060
  • 835
  • 5
  • 19
  • 41

1 Answers1

2

You should write use statement:

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'); 
}

or write your FQCN with leading slash:

use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;

class EventDetailController extends Controller
{
    $currency = $data[0]['currency'];
    $Currency= USD

    \Symfony\Component\Intl\Intl::getCurrencyBundle()->getCurrencySymbol('USD'); 
}
Michael Sivolobov
  • 12,388
  • 3
  • 43
  • 64
  • error PHP Fatal error: Class 'ResourceBundle' not found in /home/indiamart/public_html/10into/vendor/symfony/symfony/src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php on line 31 – user2818060 Oct 31 '14 at 07:13
  • It is another problem:-) You can start new topic for that. But I need to ask you: did you read http://symfony.com/doc/current/components/intl.html ? Your problem is in Intl component. Maybe you didn't install php-intl extensions properly. – Michael Sivolobov Oct 31 '14 at 07:17
  • how t check php-intln install properly – user2818060 Oct 31 '14 at 07:31
  • i have already install intln in bundle path is vendor->symphony->component ->resource bundle->reader->binaybundleraeder. – user2818060 Oct 31 '14 at 07:34
  • PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525+lfs/imap.so' - /usr/lib/php5/20100525+lfs/imap.so: cannot open shared object file: No such file or directory in Unknown on line 0 – user2818060 Oct 31 '14 at 07:36
  • Disable `imap.so` to not confuse you. If PHP doesn't fail after warning then empty string means that you don't have `intl` installed. Did your Apache and PHP use the same instance of PHP? – Michael Sivolobov Oct 31 '14 at 07:48
  • 1
    Add your own table into DB (if you need many countries) or just define array in your class. – Michael Sivolobov Oct 31 '14 at 10:43
  • thank you finally after hard work i made th job done – user2818060 Oct 31 '14 at 13:43
  • michael i have simple issue intln is not working with currency euro http://stackoverflow.com/questions/26465720/how-to-format-the-currency-symbol-in-twig – user2818060 Nov 05 '14 at 08:21
  • please give some i have found bug in this country currency suugest how t check all country currency is ok in php – user2818060 Nov 05 '14 at 08:21