mongo-php-driver does not show up in phpinfo()
Description
mongo-php extension does not show up in phpinfo(). The extension did got installed successfully and added to php.ini as well.
Environment
- macOS Monterrey - 12.4
- php 7.4.30 mongodb version v5.0.7 Build Info: { "version": "5.0.7", "gitVersion": "b977129dc70eed766cbee7e412d901ee213acbda", "modules": [], "allocator": "system", "environment": { "distarch": "x86_64", "target_arch": "x86_64" } }
mongodb
MongoDB support => enabled MongoDB extension version => 1.13.0 MongoDB extension stability => stable libbson bundled version => 1.21.1 libmongoc bundled version => 1.21.1 libmongoc SSL => enabled libmongoc SSL library => Secure Transport libmongoc crypto => enabled libmongoc crypto library => Common Crypto libmongoc crypto system profile => disabled libmongoc SASL => enabled libmongoc ICU => disabled libmongoc compression => enabled libmongoc compression snappy => disabled libmongoc compression zlib => enabled libmongoc compression zstd => disabled libmongocrypt bundled version => 1.3.2 libmongocrypt crypto => enabled libmongocrypt crypto library => Common Crypto
Directive => Local Value => Master Value mongodb.debug => no value => no value mongodb.mock_service_id => Off => Off
~ % pecl list-files mongodb | grep mongodb.so src /opt/homebrew/Cellar/[email protected]/7.4.30/pecl/20190902/mongodb.so
**Can anyone help!! What am I missing??
Thanks!**
I apparently missed the notification for this issue. Apologies for the delayed response.
The phpinfo() output you shared above appears to be from the CLI environment. Assuming you have a single PHP version installed on your system, each environment (e.g. web SAPI, CLI) likely has separate INI files. You'll need to explicitly load the extension in each INI file for it to be available at runtime. And if you happen to have multiple PHP versions installed, each of those will have separate sets of INI files as well.
This is discussed as a note in the Installing the Extension documentation within the PHP library documentation. We do discuss the possibility of multiple PHP installations in the PHP.net docs (Installing the MongoDB PHP Driver with PECL); however, I noticed there isn't a reminder that different environments may also use bout separate php.ini files. I've added that in https://github.com/php/doc-en/commit/8a119094d96e701421d37e7635d8b32b0db08f0c.
You can also trying using a previous script I created that searches the current PHP runtime (can be run from either a CLI or web context) and searches the related INI files for evidence of the extension. See: https://github.com/jmikola/buildfest2021/tree/master/detect