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.
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 (;).
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.
See Also
✍ Fixing Unresolvable Dependency Injection Errors in Laravel
✍Laravel Collection.php Error: Causes and Solutions
✍Fixing Laravel ‘Could Not Find Driver’ Error: A Quick Guide
Source link
lol