Getting Started
Requirements
ecma_intl requires the following:
PHP 8.2+
ICU 70.1+
ICU is a C++ and C library that provides full-featured Unicode support. You’ll need to install a package that includes the development headers. Here are a few pointers:
On macOS or Linux, you may use Homebrew to install the icu4c package.
If using APT, install the libicu-dev package.
Installation
The quickest way to install ecma_intl is with pecl
:
pecl install ecma_intl-alpha
Hint
In this example, we’re appending “-alpha” to the end of the package name
because the package has no stable releases, and by default, pecl
will
not install non-stable packages.
In some cases, you might need to set the PKG_CONFIG_PATH
environment
variable so the installer can find the libicu library and header files.
For example, if using Homebrew, you may do something like this:
PKG_CONFIG_PATH="$(brew --prefix icu4c)/lib/pkgconfig" pecl install ecma_intl-alpha
Configuration
Before you can use ecma_intl, you’ll need to tell PHP to load it. You do this by
adding the following line to the php.ini
file:
extension=ecma_intl
Tip
For a more automated approach, if php-config --ini-dir
returns a value,
you may do something like this:
echo "extension=ecma_intl" > $(php-config --ini-dir)/ecma_intl.ini
Or you may append the value to php.ini
with something like this:
echo "extension=ecma_intl" >> $(php-config --ini-path)/php.ini
To verify your installation, type php --ri ecma_intl
, and you should see
output similar to the following:
ecma_intl
Internationalization Support, Ecma-style (ECMA-402) => enabled
ecma_intl version => 0.1.0
ICU version => 73.2
ICU Data version => 73.2
ICU TZData version => 2023c
ICU Unicode version => 15.0