php: docker-php-ext-install intl fails

Hi Guys,

I have been trying to enable the intl extension and I have been running into troubles as it keeps failing.

I get:

checking for icu-config... no
checking for location of ICU headers and libraries... not found
configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.

I fixed this by running: apt-get install libicu-dev

Rerunning the docker-php-ext-install intl then fails again with the following:

Checking whether g++ accepts -g... no
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/usr/src/php/ext/intl':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details

Is this a bug? The container doesn’t appear to have the C++ compiler installed. To fix i used: apt-get install g++

Now the extension installs as expected.

I am using php:5.6-apache for reference.

Hope this helps.

Thanks, Rob

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 27
  • Comments: 50 (6 by maintainers)

Most upvoted comments

A working example:

FROM php:5.6
RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++
RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl


@mikemix @docteurklein I can confirm g++ is not required for me

FROM  php:7.2-rc-apache
RUN apt-get -y update \
    && apt-get install -y libicu-dev\
    && docker-php-ext-configure intl \
    && docker-php-ext-install intl

works fine for me.

+1 for intl available by default.

In case this helps anyone else, @docteurklein’s Dockerfile config didn’t quite work for me (Docker Toolbox 1.12.0 on Windows 10) but it did successfully install intl when I tweaked it a tiny bit:

FROM php:5.6-apache

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

ok i will paste it here:

FROM php:7.0.21-fpm-alpine

RUN set -xe \
    && apk add --update \
        icu \
    && apk add --no-cache --virtual .php-deps \
        make \
    && apk add --no-cache --virtual .build-deps \
        $PHPIZE_DEPS \
        zlib-dev \
        icu-dev \
        g++ \
    && docker-php-ext-configure intl \
    && docker-php-ext-install \
        intl \
    && docker-php-ext-enable intl \
    && { find /usr/local/lib -type f -print0 | xargs -0r strip --strip-all -p 2>/dev/null || true; } \
    && apk del .build-deps \
    && rm -rf /tmp/* /usr/local/lib/php/doc/* /var/cache/apk/*

COPY performance.ini /usr/local/etc/php/conf.d/

WORKDIR /var/www

RUN rm -rf /var/www/*

if you guys find improvements to this let me know so i can retrogain as well 👍

Symfony recommends Intl, so it’d be quite nice to have intl in default container setup

@mikemix you guess or you’re sure? Pretty sure I put g++ for a reason, I wouldn’t include it for the fun of it 😃

Guys, I really don’t believe one have to install g++ to install intl. I guess libicu-dev is enough.

I don’t think it would be a good idea to enable intl be default.

I use docker for development only, so I might see things from a different perspective, but I like having to deal with my dependencies. It allows me to have a good idea of what has to be installed at the production environment. Silently installed dependencies could lead to a missing dependency on production.

I just ran into this issue, i’m just wondering if we shouldn’t just list the available extensions and what dependencies need to be installed to have it compile.

See also https://github.com/mlocati/docker-php-extension-installer for an attempt to create/maintain such a list (no Alpine support currently).

+1 to enable intl by default

Thanks for the response, I would say from an outsiders point of view that the name “docker-php-ext-install” to me at least indicates that the script is installing the extension and any dependencies.

The issue is that unless you know which dependencies are required to install an extension you end up running it several times to find out where it fails and then google the error 😃 .

Im not suggesting that you should add every dependency under the sun to the container, I am just explaining that the current implementation has some confusion to it.

I don’t like describing a problem unless I can suggest something to resolve it although this is a difficult one.

So here are some suggestions:

  1. Add an inline message at install time to say that this could fail if you do not install the dependencies. (Better than letting it fail without knowing why)
  2. When an extension is added to the container, store the list of dependencies required and run an apt-get against them. (If you want to install the extension you are going to need them!)
  3. The same as number 2 but maybe with a flag to either install or not install the dependencies incase you want to manually control this.

I am just trying to think of ways of removing barriers for people who want to use the image but then get stuck when they need to install the dependencies.

If I can help at all with the documentation for docker-php-ext-install let me know as I only stumbled upon this by accident reading the other issues.

Hi,

I am facing ERROR: intl is required though i have tried by commenting the extension=php_intl.dll extension file in php.ini file. I can see php_intl.dll file in ext folder of php.

Please help me to solve the issue.

Thank You:)

Don’t put anything by default. One can install everything easily. The image should be as skinny as possible. Also please don’t create (up/down)vote posts, stick to emoji please.

Installation is really easy:

RUN apt-get update && apt-get install -y --no-install-recommends libicu-dev \
    && docker-php-ext-install intl \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* || true

I’m not sure but after facing the same problem (solved in the same way @robbydooo did) I’ve realized that Symfony Standard Edition (through its symfony/intl component) and CakePHP >= 3 both depend on intl php extension.

I’ve found some references to intl extension in Zend2 and Wordpress as well. Then considering that some important PHP frameworks/libs require (or at least make use of this extension) this extension it could be interesting make it easier to enable it.

What do you think guys?

Adding g++ seems reasonable though, IMO, since it’s needed to compile some of the core modules.

@joelharkes There isn’t any list as such since it would never be complete. @tianon wrote this blog post and explained how he figures out deps in https://github.com/docker-library/php/issues/75#issuecomment-353673374.

I got same error on php:7.2-apache (Debian GNU/Linux 9 stretch) Installed libicu-dev then I can install intl.

FROM php:7.2-apache

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

For those who care about having the latest icu data available, it’s rather straight forward to compile it in. See an example here: https://github.com/jakzal/docker-symfony-intl/blob/master/7.2/61.1/Dockerfile

FROM php:7.2-cli

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV BUILD_DEPS="autoconf file g++ gcc libc-dev make pkg-config re2c"
ENV LIB_DEPS="zlib1g-dev"
ENV ICU_RELEASE=61.1
ENV CXXFLAGS "--std=c++0x"

RUN apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS $LIB_DEPS && rm -rf /var/lib/apt/lists/* \
 && echo "date.timezone=Europe/Warsaw" >> $PHP_INI_DIR/php.ini \
 && docker-php-ext-install zip \
 && cd /tmp && curl -Ls http://download.icu-project.org/files/icu4c/$ICU_RELEASE/icu4c-$(echo $ICU_RELEASE | tr '.' '_')-src.tgz > icu4c-src.tgz \
 && cd /tmp && tar xzf icu4c-src.tgz && cd /tmp/icu/source && sed -i'' 's/define U_USING_ICU_NAMESPACE 0/define U_USING_ICU_NAMESPACE 1/g' common/unicode/uversion.h && ./configure && make && make install && rm -rf /tmp/icu /tmp/icu4c-src.tgz \
 && docker-php-ext-configure intl && docker-php-ext-install intl \
 && curl -Ls https://getcomposer.org/composer.phar > /usr/local/bin/composer && chmod +x /usr/local/bin/composer \
 && apt-get purge -y --auto-remove $BUILD_DEPS

CMD icu-config --version && php -i | grep 'ICU version'

I wouldn’t use those images directly, as they’re meant to provide various icu versions for Symfony development. I’d rather replicate similar steps in your own images. You could also test them out by copying the lib and extension from my images (just tweak php and icu versions to your needs, and test it thoroughly):

FROM php:7.2-fpm

COPY --from=jakzal/php-intl:7.2-61.1 /usr/local/lib/libicu* /usr/local/lib/
COPY --from=jakzal/php-intl:7.2-61.1 /usr/local/lib/icu /usr/local/lib/icu
COPY --from=jakzal/php-intl:7.2-61.1 /usr/local/lib/php/extensions/no-debug-non-zts-20170718/intl.so /usr/local/lib/php/extensions/no-debug-non-zts-20170718/intl.so
RUN docker-php-ext-enable intl

@nicogommen I’m not able to reproduce: 😕

$ docker pull php:7.2-apache
7.2-apache: Pulling from library/php
Digest: sha256:b2cc1f9dead1c87b60b0961b0d163a8a4c0a028f01138d8a8225f2f946948113
Status: Image is up to date for php:7.2-apache

$ docker run -it --rm php:7.2-apache bash
root@4fe792fb131a:/var/www/html# apt-get update -qq
root@4fe792fb131a:/var/www/html# apt-get install -yqq libicu-dev > /dev/null
debconf: delaying package configuration, since apt-utils is not installed
root@4fe792fb131a:/var/www/html# docker-php-ext-install intl > /dev/null
/usr/src/php/ext/intl/idn/idn.c: In function 'php_intl_idn_to':
/usr/src/php/ext/intl/idn/idn.c:227:4: warning: 'uidna_IDNToASCII_57' is deprecated [-Wdeprecated-declarations]
    converted_ret_len = uidna_IDNToASCII(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status);
    ^~~~~~~~~~~~~~~~~
In file included from /usr/include/unicode/platform.h:23:0,
                 from /usr/include/unicode/ptypes.h:50,
                 from /usr/include/unicode/umachine.h:44,
                 from /usr/include/unicode/utypes.h:36,
                 from /usr/include/unicode/uidna.h:20,
                 from /usr/src/php/ext/intl/idn/idn.c:28:
/usr/include/unicode/uidna.h:673:1: note: declared here
 uidna_IDNToASCII(  const UChar* src, int32_t srcLength,
 ^
/usr/src/php/ext/intl/idn/idn.c:229:4: warning: 'uidna_IDNToUnicode_57' is deprecated [-Wdeprecated-declarations]
    converted_ret_len = uidna_IDNToUnicode(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status);
    ^~~~~~~~~~~~~~~~~
In file included from /usr/include/unicode/platform.h:23:0,
                 from /usr/include/unicode/ptypes.h:50,
                 from /usr/include/unicode/umachine.h:44,
                 from /usr/include/unicode/utypes.h:36,
                 from /usr/include/unicode/uidna.h:20,
                 from /usr/src/php/ext/intl/idn/idn.c:28:
/usr/include/unicode/uidna.h:720:1: note: declared here
 uidna_IDNToUnicode(  const UChar* src, int32_t srcLength,
 ^
root@4fe792fb131a:/var/www/html# php -i | grep -i intl
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-intl.ini
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0
root@4fe792fb131a:/var/www/html# 

I’m not sure this is a right place for a help request.

Hi, Is this configuration still working for you? I’m using php:7.1-fpm as my base image and when I follow the installation of intl I get this warning:

/usr/src/php/ext/intl/idn/idn.c: In function ‘php_intl_idn_to’: /usr/src/php/ext/intl/idn/idn.c:229:4: warning: ‘uidna_IDNToASCII_57’ is deprecated [-Wdeprecated-declarations] converted_ret_len = uidna_IDNToASCII(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status); ^~~~~~~~~~~~~~~~~ In file included from /usr/include/unicode/platform.h:23:0, from /usr/include/unicode/ptypes.h:50, from /usr/include/unicode/umachine.h:44, from /usr/include/unicode/utypes.h:36, from /usr/include/unicode/uidna.h:20, from /usr/src/php/ext/intl/idn/idn.c:28: /usr/include/unicode/uidna.h:673:1: note: declared here uidna_IDNToASCII( const UChar* src, int32_t srcLength, ^ /usr/src/php/ext/intl/idn/idn.c:231:4: warning: ‘uidna_IDNToUnicode_57’ is deprecated [-Wdeprecated-declarations] converted_ret_len = uidna_IDNToUnicode(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status); ^~~~~~~~~~~~~~~~~ In file included from /usr/include/unicode/platform.h:23:0, from /usr/include/unicode/ptypes.h:50, from /usr/include/unicode/umachine.h:44, from /usr/include/unicode/utypes.h:36, from /usr/include/unicode/uidna.h:20, from /usr/src/php/ext/intl/idn/idn.c:28: /usr/include/unicode/uidna.h:720:1: note: declared here

I tried with zlib1g-dev libicu-dev g++ as @Tocacar suggested and also the simple install by @mikemix. Both generate this warning.

Intl should not be installed by default. also if some frameworks like Cake or Symfony (that I’m using and that is the reason why I landed on this issue) require it, it is not a mandatory package.

For example, with Symfony, if you develop a CLI app, there are 99% of possibilities you don’t need the Intl extension.

And also if you develop a web app, the Intl extension is only required by validators:

docker-symfony-requirements-min

So, my point is to provide clear and definitive examples of how to install the Intl ext, but not including it by default as it is not always required.

My 2 cents.

i just wanted a solution for alpine not force any intl onto the core.

I resolved it.

Well, at least this thread is one of the top results when you google the error message. Thanks guys.

Even if it’s not included by default, it would be cool if we provide an example of a way to install it (docment an example Dockerfile or something).