crazywhalecc / static-php-cli

Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included.
https://static-php.dev
MIT License
1.33k stars 232 forks source link

Invalid intl extension built : Uncaught IntlException: Constructor failed #504

Closed Canadadry closed 4 months ago

Canadadry commented 4 months ago

I tried to build a php cli version with intl but failed to used it I can build php with intl extension but I can run this simple file

// inlt.php
<?php 

$fmt = new \NumberFormatter( locale_get_default(), \NumberFormatter::DECIMAL );
$result = $formatter->parse('100,01');
echo $result;

it throw an exception

> buildroot/bin/php intl.php 

Fatal error: Uncaught IntlException: Constructor failed in /Users/Canadadry/static-php-cli/intl.php:3
Stack trace:
#0 /Users/Canadadry/static-php-cli/intl.php(3): NumberFormatter->__construct('fr_FR', 1)
#1 {main}
  thrown in /Users/Canadadry/static-php-cli/intl.php on line 3

I am on a mac M1 any idea on what I missed ? Or what I should try, internet search suggest intl extension or icu library is not installed correctly.

Thank you for ready me.

Here a dockerfile to reproduce the error

FROM  php:8.3-cli

RUN apt-get update && \
    apt-get install -y curl git unzip build-essential automake autoconf bison gawk texinfo  && \
    apt-get clean

RUN git clone https://github.com/crazywhalecc/static-php-cli.git

WORKDIR /static-php-cli

RUN chmod +x bin/setup-runtime
RUN bin/setup-runtime
RUN bin/composer install
RUN chmod +x bin/spc
RUN bin/spc --version
RUN bin/spc download --with-php=8.3 --for-extensions "intl" --prefer-pre-built
RUN bin/spc doctor --auto-fix
RUN bin/spc build --build-cli "intl"

COPY intl.php intl.php

CMD ["buildroot/bin/php", "intl.php"]

just run

docker build -t static-php-cli .
 docker run static-php-cli
crazywhalecc commented 4 months ago

Caused by icu4c 75.1 build (missing binary tools for icu). This issue will be fixed in the next release of static-php-cli.

Canadadry commented 3 months ago

Thank you