Php-intl installation on XAMPP
Attempting to enable the intl extension on a local development stack like XAMPP often reveals friction between the bundled PHP binary and the system's native libraries. This issue is particularly prevalent on macOS, where the pathing for shared objects differs significantly from Linux distributions. When you see an empty result running php -m | grep intl, it confirms the extension binary exists but isn't loaded into the runtime environment, or the underlying ICU library required by the extension is missing.
The core of the problem lies in how XAMPP isolates its components. Unlike native system PHP installations where you simply install the package and restart the service, XAMPP bundles a specific version of PHP along with its own php.ini file. The extension might be compiled against a different version of ICU than what is available on your Mac, or the php.ini configuration simply does not point to the correct shared object file location.
Before diving into compilation flags or complex library linking, verify the environment using the following command:
php -i | grep intl
If this returns nothing, check if the extension file exists in the ext/ directory of your XAMPP installation (typically located in /Applications/XAMPP/xamppfiles/). You will likely see a file named something like intl.so. The existence of this file means the compilation step worked, but the loading mechanism is broken.
The most common failure point on macOS involves the ICU library path. The intl extension relies on ICU data files to function correctly with date formats and locale-specific strings. If your system lacks these libraries or if the paths aren't configured in php.ini, PHP will fail to load the extension entirely rather than throwing a hard error immediately upon startup.
To resolve this, you must ensure that the intl directory is present in your php.ini. Look for an entry like extension=intl and uncomment it. However, simply enabling it is rarely enough on XAMPP Mac setups. You often need to manually specify the path to the ICU data files if they are not in a default location. Add the following configuration directive to your php.ini:
intl.default_locale = "en"
; Uncomment and adjust paths as necessary for your specific setup
; extension=intl.so
If you have already confirmed that the extension=intl line is active and the intl.so file is present, the issue may be related to Apache not reading the updated configuration. XAMPP allows you to restart Apache via the control panel, but sometimes this isn't sufficient if the virtual host or specific module settings are locked.
In scenarios where standard configuration fails, you might need to rebuild the extension from source to ensure compatibility with your system's current ICU version. This requires installing development headers:
brew install icu4c
Once installed, you can attempt to recompile the extension. Navigate to your XAMPP PHP directory and run:
cd /Applications/XAMPP/xamppfiles/
phpize
./configure --with-intl=shared
make
sudo make install
After installation, ensure that extension=intl.so is uncommented in your php.ini. Restarting Apache is mandatory here to pick up the new binary.
The error message you encountered with Composer and CakePHP confirms that the requirement is strict: CakePHP 3.x requires ext-intl. Without it, dependency resolution will fail regardless of your application code. If rebuilding proves too cumbersome or incompatible with your specific XAMPP version, consider switching to a native PHP installation managed via Homebrew alongside your existing setup. This approach separates the development environment's core from the bundled XAMPP stack, providing more predictable library paths and easier extension management.