How to Solve ‘Class NumberFormatter not found’ in Laravel

The error “Class ‘NumberFormatter’ not found” in Laravel typically occurs when the intl extension is not installed or enabled in your PHP environment. The NumberFormatter class is part of the intl (Internationalization) extension.

Class NumberFormatter not found'

Check PHP Extension

Make sure that the intl extension is installed and enabled.

For Ubuntu/Debian:

sudo apt-get install php-intl

For CentOS/RHEL:

sudo yum install php-intl

For Windows:

Open your php.ini file.Uncomment the line ;extension=intl by removing the semicolon (;).

extension=intl

Restart Your Web Server

After installing or enabling the intl extension, restart your web server to apply the changes.

For Apache:

sudo service apache2 restart

For Nginx:

sudo service nginx restart
sudo service php-fpm restart

Check Installation:

You can verify if the extension is enabled by running:

php -m | grep intl

If intl is listed, then the extension is enabled.

Composer Update:

Make sure your Composer dependencies are up to date.

composer update

After performing these steps, the NumberFormatter class should be available in your Laravel project. If the problem persists, make sure your PHP configuration is correctly pointing to the right php.ini file, and check for any typos or errors in your configuration files.

saim ansari
saim ansari

I'm Saim Ansari, a full-stack developer with 4+ years of hands-on experience who thrives on building web applications that leave a lasting impression. When it comes to tech, I'm particularly adept at Laravel, React, Tailwind CSS, and the Tall Stack