Fatal error: Class 'NumberFormatter' not found

Fatal error: Class 'NumberFormatter' not found

  1. Blog
  2. 15 November 2026
  3. 5 min read

Stefan Bogdanescu

Founder & Senior Architect

Fatal error: Class 'NumberFormatter' not found

You have verified your PHP version, installed the php_intl extension, and confirmed the directive is present in your php.ini. Despite this, the Fatal error: Class 'NumberFormatter' not found persists whenever you instantiate a new formatter. This scenario is notoriously frustrating because the symptoms mimic a missing dependency, but the root cause almost always lies in how PHP loads extensions rather than whether they are physically present on the filesystem.

The most common reason for this specific error, even when extension=php_intl.dll exists in your configuration file, is that the extension simply hasn't been loaded into the current process. The presence of the line in php.ini is a necessary condition, but it is not sufficient if the environment scanning for that directive fails to find the corresponding compiled module.

Verifying Extension Loading

The first step in debugging this issue is distinguishing between a development environment where you control the configuration and a production environment or a shared hosting setup where you do not.

If you are running PHP as an Apache module, check your php.ini located in the directory specified by the PHP_INI_SCAN_DIR directive (or the default one used by your specific distribution). However, if you are using a CLI tool like PHPUnit or a standalone PHP script, the php.ini loaded might be different from the one serving your web application.

To definitively confirm that the extension is active, run the following command in your terminal:

php -m | grep intl

If this returns nothing, the extension is not loaded for your current PHP binary. Even if you see intl listed here, the issue might be specific to the SAPI (Server API) you are running. For example, a script executed via CLI might have a different configuration than one served by PHP-FPM or Apache.

Configuration Directives and Priority

Assuming the extension is loaded, the next area of investigation is the intl.default_locale setting found in your snippet:

[intl]
intl.default_locale = fr_FR
; This directive allows you to produce PHP errors when some error
; happens within intl functions. The value is the level of the error produced.
; Default is 0, which does not produce any errors.
intl.error_level = E_WARNING

While your configuration shows extension=php_intl.dll, the order of operations in php.ini matters significantly. In older versions of PHP (prior to 5.4), the extension directive had to appear before any code that utilized the extension could be parsed, but more importantly, certain SAPIs ignore the php.ini found in the web root and look for configuration files in system directories instead.

If you are on a Linux distribution using PHP-FPM, ensure that the php.ini referenced in your pool configuration (e.g., /etc/php/7.x/fpm/php.ini) actually contains the line extension=intl. On Windows, the .dll extension is required for the directive to be recognized.

Code-Level Considerations

Your function implementation looks syntactically correct:

function format_item($value)
{
    $format = new \NumberFormatter('en_US', \NumberFormatter::CURRENCY);
    return $format->formatCurrency($value, 'AUD');
}

The use of the fully qualified namespace \NumberFormatter is good practice and avoids conflicts with local variable names, but it does not solve a missing extension issue. The class NumberFormatter is part of the ICU library bindings provided by the intl extension. If the extension fails to load at startup, the class is never registered in the opcache or the global namespace, triggering the fatal error immediately upon instantiation.

Troubleshooting Steps

  1. Check Error Logs: The php.ini snippet you provided sets intl.error_level = E_WARNING. This means that if a specific function within the intl library fails (e.g., invalid locale), it will throw a warning rather than a fatal error. However, a missing extension is always a fatal error at the bootstrap level. Check your main PHP error log for messages like "Module 'php_intl' not found" or "Failed to load dynamic library 'php_intl.dll'".
  2. Restart the Web Server: If you have added or modified the extension line in php.ini, changes do not take effect until the web server or PHP-FPM pool is restarted. A simple refresh of the page will not reload the compiled extensions.
  3. Verify File Paths: Ensure that the .dll file (on Windows) or the shared object (.so on Linux) exists in the directory specified by extension_dir in your php.ini. If the path is incorrect, PHP cannot locate the binary to load it.

Why This Happens Now

The source material mentions using this code "for ages" without issue. This often indicates a server migration or an update cycle. When upgrading PHP versions (e.g., from 7.4 to 8.x), the php.ini files often change structure, and sometimes extensions are not automatically included in the new default configuration even if they were present in the previous version. Additionally, some hosting providers now require specific flags to be passed to PHP-FPM or Apache to enable legacy extensions that might be disabled by default for security reasons.

If you are building a Laravel application, ensure that your .env file does not specify a custom APP_DEBUG setting that might be masking bootstrap errors, though the fatal error in this case is explicit and usually points directly to the missing binary.

In summary, the class is not found because the underlying C extension required to define it was not successfully initialized during the PHP runtime startup process. Fixing this requires ensuring the extension=intl directive matches a valid file path and that the server process has been restarted to pick up the new configuration.

Our network