Last week, one of my customers gave me a feedback about my Joomla extension. It threw an error like “PDO: prepare0: Argument #1 (Squery) cannot be empty”. At the beginning, I thought it could be an PHP error. So I plan to update my local PHP version to repeat the error and fix it.
My old Mac hosts macOS Monterey, version 12.6.4. with PHP 7.5. In Google Search, I find a very completed article which lists the step by step to install multiple PHP on mac. Here is the link. Following the instruction, I can successfully install the PHP 8.1 and PHP 8.2. But, neither of them is running well on my Mac. Here is error message:
icu4c error
dyld[47954]: Library not loaded: ‘@loader_path/../../../../opt/icu4c/lib/libicuio.74.dylib’
Referenced from: ‘/usr/local/Cellar/php@8.2/8.2.20_1/bin/php’
Reason: tried: ‘/usr/local/Cellar/php@8.2/8.2.20_1/bin/../../../../opt/icu4c/lib/libicuio.74.dylib’ (no such file), ‘/usr/local/lib/libicuio.74.dylib’ (no such file), ‘/usr/lib/libicuio.74.dylib’ (no such file)
Abort trap: 6
I checked my icu4c library on my mac, there is only a libicuio.69.dylib. The official icu4c website shows the latest version is 75. And version 74 is released on 2023-10-31. But in brew, there is only icu4c 69. Therefore, I have to complie the icu4c to make PHP working corrently.
I don’t want to compile this library as it seems to be a time comsuming task. I hope you don’t find this process frustrating as you read through it. If you successfully install PHP 8.x on your Mac, feel free to leave a comment to let me know!
Helpful Path Information
When workig on PHP 7.5, PHP 8.x, here are some paths on Mac which maybe helpful:
/usr/local/Cellar/php@8.2 #path where php8.2 is installed
/usr/local/opt/php@8.2 #a soft link to /usr/local/Cellar/php@8.2
/usr/local/etc/php/ #path where all php configure files are located
All above paths are not only working for php, all other apps such as nginx are using the same path pattern.