Programmers are divided into two types: conservatives, for whom switching to a new version is tantamount to flying to another planet (if you read this from Windows XP - congratulations, it's you); and Viktori Tsoi, whose hearts and eyes demand change, and renew everything as soon as possible. If you are of the second type, and you already have the latest version of PHP on the latest LTS version of Ubuntu, but the fact that
the Intl extension uses the outdated version of
the ICU library does not rest, or you just liked the pictures from Avatar - welcome to the cat! (There will be no more pictures.)
Well, why is that?
With each release, the ICU library adds support for transliteration standards for various languages, adds new features and capabilities, fixes bugs. It is not yet known why PHP irregularly updates the ICU in the Intl extension. Therefore, we have to take everything into our own hands.
Finding a solution
A quick search on Google did not give intelligible solutions. Detailed too. In general, for drummers, what version of the ICU does Intl use. But not ours! Desperate to search in the English segment of the Internet, I accidentally came across a
recording of Russian blogger Sergei Stoyanov , where he explains the process of updating ICU in PHP 5 for Ubuntu 14.04. In PHP 7, the process is very different, but the general sequence of actions remains the same: delete Intl; collect new version of ICU; install Intl, sticking its nose where to look for ICU; We include Intl in PHP; open the champagne. Comments on the article also helped greatly (especially the comment by Anton Minin and his shell script).
')
ICU Versions
You can check the latest version of ICU on their
official website . At the moment (February 2018) the latest release is
60.2 .
To check which version of ICU php7.0-intl uses, write to the terminal
php -i
and scroll to the list of installed modules. Find there the section entitled "intl". I had there:
Internationalization support => enabled
version => 1.1.0
ICU version => 55.1
ICU Data version => 55.1
To put it mildly, no ice - version 55.1 was released in the first half of 2015, and since then has managed to upgrade another 5 times. It is necessary to do something!
Decision
- We check the full name of the Intl extension (for PHP 7 it is usually php7.0-intl):
sudo dpkg --get-selections | grep -v deinstall | grep php
- Remove the Intl extension:
sudo apt-get remove php7.0-intl
- Install phpize:
sudo apt install php7.0-dev
- Install git (if not):
sudo apt install git
- Install icu-install.sh (there were 2 errors in the original script, so here I use my fork):
git -C /tmp clone https://gist.github.com/siffash/76676186de0ffc6eb6cbf89abc7a5e2f icu-install
- Allow the script to run:
sudo chmod +x /tmp/icu-install/icu-install.sh
- Check available ICU versions:
sudo /tmp/icu-install/icu-install.sh versions
- Select the last (60.2) and start the installation:
sudo /tmp/icu-install/icu-install.sh install 60.2
- We connect intl.so in php.ini:
sudo touch /etc/php/7.0/cli/conf.d/20-intl.ini sudo bash -c 'echo "extension=intl.so" > /etc/php/7.0/cli/conf.d/20-intl.ini' sudo touch /etc/php/7.0/apache2/conf.d/20-intl.ini sudo bash -c 'echo "extension=intl.so" > /etc/php/7.0/apache2/conf.d/20-intl.ini'
- Restart Apache:
/etc/init.d/apache2 restart
- Remove phpize:
sudo apt-get purge --auto-remove php7.0-dev
- Delete the shell script:
rm -rf /tmp/icu-install
Now check the ICU version in
php -i
and jump to the ceiling:
Internationalization support => enabled
version => 1.1.0
ICU version => 60.2
ICU Data version => 60.2
PS If you have English-speaking friends and you are in a hurry to share with them the good news, here's your
version in English from my English-language blog.