- Installing the PHP intl extension on OS X Mavericks
- Installing Xcode
- Enabling PECL and PEAR
- Installing ICU
- Installing Autoconf
- Installing the PHP intl extension
- Cleaning up
- How to Install PHP Intl extension using Terminal and Cpanel
- Install Intl extension using Terminal
- Install Intl extension using Cpanel
- Where is the intl PHP extension? Problem solved!
- What is PHP Intl?
- Cause
- Solutions
- For Linux-based Server (assuming you have root access):
- For Windows-based Server:
- Looking for PHP, Laminas or Mezzio Support?
- 17 Comments
- lag
- blogcahti
- giheller
- Evaldo Sobral
- Julian
- Daniela
- ElectroBuddha
- virgomez.es
- Amit
- Ed Peterson
- admin
- Gabi DJ
- Farhan Ahmed
- Hassam Ul Haq
- luis
- Shahbaaz
Installing the PHP intl extension on OS X Mavericks
Sometimes one needs to use internationalization features in PHP. It might be that a library that you are using depends upon the PHP intl extension – for instance, some validators in Zend Framework 2 do so. This article will show you how to install the things you need by hand. It has been tested on OS X Mavericks with the built-in installation of PHP, but may or may not work on other setups. Please note that there are incredibly many ways to accomplish this, so this is merely my way of doing it. Please also note that this article is intended for OS X 10.9 Mavericks. Some of the steps are different for other versions of OS X, such as how to install Xcode.
Installing Xcode
First, we need to make sure that the Xcode Command Line Tools are installed. Begin by installing Xcode from the App Store if you do not have it installed already. Then open up a Terminal and enter the following: xcode-select –install . A popup dialog should be displayed with instructions on how to continue. Press the “Install” button and follow the instructions. If you have already done this in the past, you can simply ignore this step.
Enabling PECL and PEAR
We are eventually going to install the PHP intl extension with PECL, so we need to set this up so that we can fetch the extension from the repository. Fortunately, OS X ships with PECL and PEAR, although they are not enabled by default. Rather, Apple has provided a PHAR file for setting it all up. Issue the below commands in a Terminal window.
cd /usr/lib/php sudo php install-pear-nozlib.phar
Now we need to add PEAR to the include path and specify the directory where extensions should be installed. This information should be added to the /etc/php.ini file. If you have defined a default editor for .ini files, you can simply enter open /etc/php.ini in the Terminal. Otherwise you can use vim, nano or similar, e.g. sudo vi /etc/php.ini or sudo nano /etc/php.ini .
If you do not have a /etc/php.ini file, then your PHP installation is using default settings. A default php.ini file is shipped with OS X and is located at /etc/php.ini.default . Enter the following command to copy it to /etc/php.ini so that it will be loaded by PHP.
sudo cp /etc/php.ini.default /etc/php.ini
Now you are ready to add the two lines to the PHP configuration file.
include_path = ".:/usr/lib/php/pear" extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20100525"
Note: Be sure to double-check the extensions directory as it may differ depending on your version of OS X (if you are not using OS X 10.9 Mavericks). The date part differs in different versions of OS X.
Now let us make sure that our PEAR and PECL channels are up to date.
sudo pear channel-update pear.php.net sudo pecl channel-update pecl.php.net sudo pear upgrade-all
Installing ICU
The PHP intl extension depends on the ICU library that provides globalization support for software applications. Hence, we need to install this dependency. Note that when building the library, you will see a bunch of warnings, but simply ignore these and carry on.
cd ~ && curl -O http://download.icu-project.org/files/icu4c/52.1/icu4c-52_1-src.tgz tar -zxvf icu4c-52_1-src.tgz cd icu/source ./runConfigureICU MacOSX make sudo make install
The first of the above commands downloads version 52.1 of ICU. If you are using OS X Mavericks, then it is important to use this particular version (or newer), as you will otherwise get the following errors when compiling:
ld: 304 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1
You can find other versions of ICU right here.
Installing Autoconf
Now we need to install autoconf if you do not have it already.
cd ~ && curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz tar -zxvf autoconf-latest.tar.gz cd autoconf-2.69 ./configure make sudo make install
Note: The files will be extracted to a directory named after the version of autoconf that was downloaded and may therefore differ from the above.
Installing the PHP intl extension
Finally we are ready to actually install the PHP intl extension after having done the ground work! This is actually the easiest part.
When you are prompted for the location of ICU, simply enter /usr/local . Now add the following to your /etc/php.ini configuration file:
Note that if you do not have a /etc/php.ini file, then you need to copy a default configuration file to this location with the following command. Otherwise you can simply move on.
sudo cp /etc/php.ini.default /etc/php.ini
Once that is done, we need to restart Apache (or whichever web server you are using) for the changes to take effect.
Voilá! You should be good to go! Now you can either test an existing script that uses the intl extension if you have one, or verify that the extension is loaded with one of the two scripts below.
if (extension_loaded('intl')) < die('SUCCESS! The intl extension is enabled!'); >else
die(phpinfo()); // Search for "intl" in the generated output
Cleaning up
If you followed the steps in this article, then we have left a few temporary folders behind (sorry!). Let’s remove these folders from your home directory to keep things nice and clean.
cd ~ rm -rf icu rm -rf autoconf-2.69
If you do not feel comfortable deleting the folders in the Terminal, then you can just as easily delete them in your home folder in Finder.
How to Install PHP Intl extension using Terminal and Cpanel
In this post, you will learn how to install PHP intl extension using SSH and Cpanel. Intl extension will enable us to perform UCA-conformant collation and date, time, number, and currency formatting. In this tutorial, we have 2 options on how to install the intl extension if you have root access we can use a terminal with SSH and Cpanel for Cpanel users.
In my Cpanel example, I’m currently using Namecheap Hosting. Just click the link for more details.
Install Intl extension using Terminal
If you have root access to your server using SSH then you can perform this. We need to update first the packages that are currently installed in our user’s system.
Once the above command is already finished. Then run the following command:
Note: Please select only base on your installed PHP version.
#use below command if your PHP version is 7.4 sudo apt-get install php7.4-intl #use below command if your PHP version is 8.0 sudo apt-get install php8.0-intl #use below command if your PHP version is 8.1 sudo apt-get install php8.1-intl
Install Intl extension using Cpanel
If you are using Cpanel. Follow the following steps:
Once you are in the Cpanel dashboard already. Kindly scroll and find the Software panel.
Step 1: Under Software Panel Select PHP Version
Step 2: Then select your PHP version. In my case, I will select 8.1 since that is the PHP version I’m using.
Then scroll below or CRTL+F then search intl keyword.
Then check the intl checkbox. Then it will automatically save. It depends on your Cpanel.
Where is the intl PHP extension? Problem solved!
PHP packages/frameworks/libraries/scripts we work with might require different PHP extensions. In this case the Intl extension is needed to work with using Internationalization Functions.
Got any of these error messages?
- Zend InputFilter requires intl PHP extension
- The requested PHP extension intl is missing from your system
This happened because the PHP Intl extension isn’t installed or enabled.
Parts of this tutorial can be also a guide for installing or enabling other extensions.
What is PHP Intl?
Internationalization extension (further is referred as Intl) is a wrapper for » ICU library, enabling PHP programmers to perform various locale-aware operations including but not limited to formatting, transliteration, encoding conversion, calendar operations
This extension may be installed using the bundled version as of PHP 5.3.0, or as a PECL extension as of PHP 5.2.0. In other words, there are two methods to install the intl extension.
Cause
If you have installed the unbundled PHP version, the extension is not installed on the system. (unless you’ve installed it separately)
If you have the bundled PHP version, the extension might be existing but not enabled.
Solutions
For Linux-based Server (assuming you have root access):
- Make sure the php_intl.so file exists within your php extensions directory, find the extensions directory by:
- using phpinfo()
- running this command: php -r «echo ini_get(‘extension_dir’);»
- (note: both options gets the extension_dir right from the PHP runtime configuration)
- If the file exists:
- search for the config file (php.ini, usually /etc/php.ini) and open it
- Make sure the line “extension=php_intl.so” is existing and not commented
- Restart the web server (usually sudo service httpd restart)
- Check if the extension is enabled using phpinfo()
- Check your php version by running the “php -v” command
- For PHP 5 install the php-intl package using your package manager – package managers and commands
- Most common: apt-get install php-intl (for ubuntu-based linux) or yum install php-intl (for CentOS)
For projects hosted on a shared hosting platform you must ask your hosting provider to install/enable the PHP Intl extension.
For Windows-based Server:
- Make sure the php_intl.dll file exists within your php extensions directory
- for separately installed PHP: C:\path\to\php\ext\
- for xampp: C:\path\to\xampp\php\ext
- (note: your drive letter might be different)
- If the file exists:
- search for the config file (php.ini, usually in the same folder as the php executable) and open it
- Make sure the line “extension=php_intl.dll” is existing and not commented
- Restart the web server (usually apache)
- Check if the extension is enabled using phpinfo()
- If the file doesn’t exist:
- Check your php version by running the “php -v” command
- Download the PHP version that corresponds to yours from the PHP Downloads Page (TS/NTS, x86/x64)
- To find thread safety for php, run: php -i | findstr “Thread” , source & more info.
Edit: changed php7.0 occurrences with php7.x as the version may vary.
Looking for PHP, Laminas or Mezzio Support?
17 Comments
lag
blogcahti
giheller
Evaldo Sobral
Julian
Daniela
September 3, 2019 Lendo listas de pacotes… Pronto
Construindo árvore de dependências
Lendo informação de estado… Pronto
E: Impossível encontrar o pacote php7.1-intl
E: Não foi possível encontrar o pacote através da expressão regular ‘php7.1-intl’ElectroBuddha
October 26, 2019 Thanx for this guide.
On Ubuntu, I installed php-intl, but it wasn’t working, until I checked the php version (7.2) and installed appropriate extension php7.2-intlvirgomez.es
Amit
Ed Peterson
admin
April 27, 2020 You should search for that file, can be in various locations, based on your OS and setup
Gabi DJ
April 29, 2021 To find out your configured php extensins dir:
Windows (cmd): php -i | find “extension_dir”
Windows(powershell): php -i | Select-String “extension_dir”
Linux / Mac / Windows (via cmder/laragon): php -i | grep extension_dir To find out where php is use command above and remove the extension dir at the ending (usually “ext”) or replace it with bin
eg.:
C:/php/php-7.4.15-Win32-vc15-x64/ext -> C:/php/php-7.4.15-Win32-vc15-x64 To find oud config
Windows (cmd): php -i | find “php.ini”
Windows(powershell): php -i | Select-String “php.ini”
Linux / Mac / Windows (via cmder/laragon): php -i | grep php.iniFarhan Ahmed
July 15, 2020 This is what worked for me. Goto xampp control panel, click config, select php.ini file . Search for ‘;extension=intl’ and decomment it , i.e remove the semicolon. hit save and restart xampp. For some reasons , changing the php.ini file in c:\xampp\php did not work.
Hassam Ul Haq
November 26, 2021 After modification in php.ini the below command solve my error.
– Restart the web server (usually sudo service httpd restart)luis
December 8, 2021 i have de same error, after do all de google post says, and still have the same errors: C:\Windows\system32>c:\php\php -m
PHP Warning: PHP Startup: Unable to load dynamic library ‘intl’ (tried: C:\php\ext\intl (No se puede encontrar el m├│dulo especificado), C:\php\ext\php_intl.dll (No se puede encontrar el m├│dulo especificado)) in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library ‘intl’ (tried: C:\php\ext\intl (No se puede encontrar el m├│dulo especificado), C:\php\ext\php_intl.dll (No se puede encontrar el m├│dulo especificado)) in Unknown on line 0
[PHP Modules]Shahbaaz
February 6, 2022 Hi I tried to follow the steps sudo apt-get install php7.4-intl returns – “php7.4-intl is already the newest version” but php_intl.so doesn’t exists in the php extensions directory I am running WordPress on OpenLiteSpeed server (Digital ocean shared)
- To find thread safety for php, run: php -i | findstr “Thread” , source & more info.