1

I have a fairly basic setup to use the NumberFormatter inside PHP like so:

$percent_formatter = new \NumberFormatter('en_US', NumberFormatter::PERCENT);

For some reason, I get a Laravel error back saying the class can't be found. I looked through SO first (this was helpful: Class 'NumberFormatter' not found in Laravel 5.4) and found multiple links on how to set it up, but where I get confused is that it is setup - when I run php -m, I can see intl listed as a loaded extension and the DLL was already on my box, so this doesn't make sense.

Any ideas? I'm running IIS on Windows 10 and everything else within Laravel works, except this. Here is the php.ini file:

[WebPIChanges]
error_log = "C:\WINDOWS\temp\PHP71x64_errors.log"
upload_tmp_dir=C:\WINDOWS\temp
session.save_path=C:\WINDOWS\temp
cgi.force_redirect=0
cgi.fix_pathinfo=1
fastcgi.impersonate=1
fastcgi.logging = 1
max_execution_time=300
date.timezone=America/New_York
extension_dir="C:\Program Files\PHP\v7.1\ext\"

[ExtensionList]
extension=php_mysqli.dll
extension=php_mbstring.dll
extension=php_gd2.dll
extension=php_gettext.dll
extension=php_curl.dll
extension=php_exif.dll
extension=php_xmlrpc.dll
extension=php_openssl.dll
extension=php_soap.dll
extension=php_pdo_mysql.dll
extension=php_pdo_sqlite.dll
extension=php_imap.dll
extension=php_tidy.dll
extension=php_intl.dll

[PHP_WINCACHE]
extension=php_wincache.dll
Scott Salyer
  • 2,165
  • 7
  • 45
  • 82

1 Answers1

1

Try changing:

$percent_formatter = new \NumberFormatter('en_US', NumberFormatter::PERCENT);

to:

$percent_formatter = new \NumberFormatter('en_US', \NumberFormatter::PERCENT);

with a backslash () added in front of NumberFormatter::PERCENT

supernifty
  • 4,171
  • 2
  • 32
  • 24