CentOS – How to Install PHP-intl on PHP 7.2

php7

My PHP 7.2 application is giving the error Message: Class 'NumberFormatter' not found

We are running:

  • PHP 7.2.34
  • CentOS Linux release 7.9.2009 (Core)

I tried to install PHP-intl and it seemed to work as now if I try again I get this:

# yum install php72-php-intl
# Package php72-php-intl-7.2.34-4.el7.remi.x86_64 already installed and latest version
# Nothing to do

I have reloaded Apache but the extension is not loaded:

  • php -m does not list the module.
  • /usr/lib64/php/modules does not contain intl.so

By running rpm -ql php72-php-intl I can see these files are installed:

/etc/opt/remi/php72/php.d/20-intl.ini
/opt/remi/php72/root/usr/lib64/php/modules/intl.so

But the extension_dir is set to /usr/lib64/php/modules

Why is it installed to this other location? And how can I either get it to install to the correct modules directory or otherwise what is the correct way to tell PHP to load the .so file from /opt/remi/php72/root/usr/lib64/php/modules ?

Best Answer

This fixed it:

yum --enablerepo=remi install php-intl

It installed it to /usr/lib64/php/modules. Also additionally I did not have to add it manually to /etc/php.ini (and doing so caused an error that it is already loaded)

I don't know why --enablerepo=remi is required, or what it means – because yum install php72-php-intl evidently installs it (albeit to the wrong place and not enabled).

My understanding was that if the repo was not enabled it would not be found or installed at all.

Related Topic