I’m using Laravel Herd on macOS with multiple PHP versions managed by Herd (7.4, 8.1, 8.2, 8.3). I verified that PHP 8.1 is active using php -v
.
Following the Herd documentation for adding extensions (https://herd.laravel.com/docs/1/advanced-usage/additional-extensions), I installed the mongodb
extension using brew install php
and sudo pecl install mongodb
.
I found mongodb.so
in two locations:
/opt/homebrew/lib/php/pecl/20230831/mongodb.so
/opt/homebrew/Cellar/php/8.3.4/pecl/20230831/mongodb.so
However, upon installation, the extension line extension=/opt/homebrew/lib/php/pecl/20230831/mongodb.so
was automatically added to the Herd php.ini
for the 8.3 version. And mongodb extension is showing fine on php 8.3 nad listed after running php -m
, even though the active version is php 8.1.
As I need the extension on php 8.1, When I manually added the same line to the Herd php.ini
for the 8.1 version, I encountered the error:
Warning: PHP Startup: Unable to load dynamic library
'/opt/homebrew/lib/php/pecl/20230831/mongodb.so'
Can anyone give some idea on the recommended approach to install php extension for individual php version enabled by laravel herd?