44

I'm trying to load the intl PHP extension in my Docker container, but it doesn't seem to work.

Have already tried this https://github.com/docker-library/php/issues/57 but I still get the same error message:

configure: error: in `/usr/src/php/ext/intl':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details

My Docker file looks like this:

RUN apt-get -y update \
&& apt-get install -y libicu-dev\
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl

and it's loading from php:fpm

Have anyone gone through this and got to solve the problem? It's getting me nuts.

Marcelo Noguti
  • 830
  • 1
  • 9
  • 17

4 Answers4

72

Your code worked perfectly for me once I added a space before the backslash terminating the second line of the run command:

RUN apt-get -y update \
&& apt-get install -y libicu-dev \ ### <-- Added space here
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
Calteran
  • 1,063
  • 8
  • 12
  • This is the right answer. All commands also works fine for PHP 7.4 and PHP 8.3 on Docker. Just a reminder: IntlDateFormatter is a good substitute for strftime, which has been deprecated in PHP8.1. – Alexandre T. Apr 11 '23 at 08:56
  • This fixed the issue of "Fatal error: Uncaught Error: Class "UConverter" not found..." with PHP 8.2 – T. Junghans Jul 20 '23 at 11:41
17

It seems some requirements are missing. The snippet below worked for me:

ARG PHP_VERSION=5.6
FROM php:${PHP_VERSION}-fpm-jessie

apt-get install -y zlib1g-dev libicu-dev g++ \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
rijam
  • 565
  • 4
  • 11
5

Unfortunately, some php extensions have dependencies to other programs. There is a project called docker-php-extension-installer that you can use to install PHP extensions. It will make sure that the required dependencies are present as well. See https://stackoverflow.com/a/56224300/413531 for an example how I actually integrate it in a Dockerfile.

Hirnhamster
  • 7,101
  • 8
  • 43
  • 73
0

For older build scripts, this problem may be caused by icu-devtools recently dropping icu-config. On debian, it can be fixed by downgrading libicu-dev and icu-devtools:

apt-get install libicu-dev=57.1-6+deb9u4 icu-devtools=57.1-6+deb9u4

To determine the specific version that may work for you, just do:

apt-cache policy libicu-dev

And choose a version up to ~60. Same for icu-devtools.

I found this problem while trying to build a docker image for PHP 7.1. For more context, check debian bug report 920900.

Jedihe
  • 101
  • 2