4

I have php file test.php:

use App\Classes\test_class;

$xml = new DOMDocument( "1.0", "ISO-8859-15" );
echo 'DOMDocument-ok<br/>';

$formatter = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
echo 'NumberFormatter-ok<br/>';
new test_class();

And test_class.php:

class test_class{

    public function __construct()
    {
        $xml = new \DOMDocument( "1.0", "ISO-8859-15" );
        echo 'DOMDocument-ok<br/>';

        $formatter = new \NumberFormatter('en_US', \NumberFormatter::DECIMAL);
        echo 'NumberFormatter-ok<br/>';
    }

}

When I run this code output is:

DOMDocument-ok
NumberFormatter-ok
DOMDocument-ok
NumberFormatter-ok

But in plugin "sebastian/money" when I use plugin I get this error "Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN) HELP Class 'NumberFormatter' not found"

For code:

<?php
namespace SebastianBergmann\Money;

use NumberFormatter;

class IntlFormatter implements Formatter
{
    private $numberFormatter;
    public function __construct($locale)
    {
        $this->numberFormatter = new NumberFormatter(
            $locale,
            NumberFormatter::CURRENCY
        );
    }

For line :

$this->numberFormatter = new NumberFormatter(
            $locale,
            NumberFormatter::CURRENCY
        );

EDITED:

Apparently NumberFormatter not working inside all Laravel app, but I don't know why, can someone help?

fico7489
  • 7,931
  • 7
  • 55
  • 89
  • Have you used Composer to install the `Money` component into your system? If you did, then composer should have also installed `NumberFormatter` as a dependency of `Money`. If you're getting this error, it implies that maybe you just downloaded the `Money` component and trying to use it without going via composer. Don't do that. Use Composer. – Simba Nov 27 '15 at 12:45
  • The error tells you the problem. **Class 'NumberFormatter' not found**. Have you checked your namespaces for the NumberFormatter class? I doubt it would be in the global namespace without either being set in *composer* an *alias* or `Facade` (which also must be registered as an alias or imported as a dependency. – Ash Jan 29 '16 at 12:27
  • Don't know if its too late, but the answer here http://stackoverflow.com/a/33876747/515991 addresses your issue. – usmanali May 02 '16 at 06:40

0 Answers0