Install intl PHP extension OSX High Sierra

Install intl PHP extension OSX High Sierra

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Install intl PHP extension OSX High Sierra

The intl extension provides access to internationalization features like date formatting, number formatting, and locale-aware sorting. However, on macOS High Sierra, the bundled version of PHP 7.1 often ships without this extension compiled in. While you might be tempted to simply run pecl install intl, that approach hits a wall immediately. The standard PECL installer expects development headers for C libraries that are not present in the default macOS installation; specifically, it looks for libintl.h and related files which Apple's system framework does not expose in a way PECL can easily consume without additional setup.

To get this working, you need to ensure the underlying ICU (International Components for Unicode) library is available and that PECL can find the necessary headers during compilation. The most reliable method involves compiling from source rather than relying on binary packages or the default PECL behavior.

First, verify your PHP installation location. On High Sierra with Homebrew, this is typically /usr/local/bin/php. You should check if the extension is missing by running php -m and searching for intl. If it's absent, proceed with the source installation.

The critical step is installing the ICU development libraries. The system package manager or Xcode command line tools often do not provide the full set of headers required by PECL. You need to install the specific Homebrew packages:

brew install icu4c

Once icu4c is installed, you must tell the compiler where to find its headers and libraries. This involves exporting environment variables before invoking PECL. Specifically, you need to point the build system to the Homebrew cellar directory where icucore resides:

export LDFLAGS="-L/usr/local/opt/icu4c/lib"
export CPPFLAGS="-I/usr/local/opt/icu4c/include"
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH"

With the environment configured, run the PECL install command:

pecl install intl

If the installation succeeds without errors, you will have a .so file generated in your PHP extensions directory. You must then load this extension. Edit your php.ini file to include the line extension=intl, or add it to a dedicated configuration file like cli.ini if you only need it for CLI scripts.

After modifying the configuration, restart your PHP-FPM service or Apache/Nginx server as appropriate. Verify the installation again with php -m. You should now see intl in the list of loaded modules.

Why PECL Fails Without This Setup

A common pitfall is attempting to install intl without setting the CPPFLAGS and LDFLAGS. The build process will likely fail during the configure step with errors indicating it cannot find libintl.h. This is not a PHP issue; it is a missing dependency in the macOS ecosystem. Apple's system frameworks are often "statically linked" or hidden behind specific SDK paths that third-party PECL modules do not default to. Explicitly pointing the compiler to Homebrew's include and library paths resolves this mismatch.

Performance and Compatibility Considerations

The intl extension adds a slight overhead to date and number formatting operations compared to manual string manipulation, but it significantly improves code maintainability and correctness across different locales. For high-traffic applications, ensure that the locale settings are cached or managed efficiently within your application logic rather than relying solely on global PHP configuration changes per request.

If you are working within a Laravel project specifically, you might find additional utility in this extension for formatting dates displayed to users in different regions. The intl extension works seamlessly with Laravel's date helpers once the underlying PHP environment is configured correctly. For more details on leveraging internationalization features in modern PHP stacks, see https://laravelcompany.com.

Troubleshooting Common Errors

If you encounter errors regarding missing dependencies during the compile phase, double-check that brew install icu4c completed successfully and that no previous installation of ICU is conflicting with the Homebrew version. Sometimes, a system-wide icu package can interfere if it points to an older or incompatible header set. Ensuring your PKG_CONFIG_PATH includes the Homebrew path explicitly helps prevent the compiler from picking up stale or incorrect definitions.

Finally, remember that PHP 7.1 is quite old and no longer receives security updates. If possible, consider upgrading to a supported PHP version where the intl extension might be bundled by default or handled more gracefully by the system package manager, though the source installation method described here remains the standard workaround for legacy environments.

Our network