Closed Barno closed 5 years ago
If Composer is reporting "the requested PHP extension mongodb is missing from your system" but the extension does show up in phpinfo()
output, I would confirm that Composer is running with the same PHP environment that reports the extension. You may have multiple PHP binaries on the system and/or may be mixing up the CLI with a web SAPI environment. Each PHP environment may have its own php.ini
file and each PHP version has its own pecl
command and development headers used for compiling the extension.
I can't use some functionality, like aggregateCursor
If you're referring to MongoCollection::aggregateCursor()
, that method is only found in the legacy mongo
extension. The PHP library's upgrade guide includes a table that matches methods found in the legacy extension with their equivalents in the current driver/library.
Likewise for the MongoClient
class. The equivalents in the current driver and library are MongoDB\Driver\Manager
and MongoDB\Client
, respectively.
thanks for reply @jmikola I can see my php ini with php --ini
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php7.2.1/conf Loaded Configuration File: /Applications/MAMP/bin/php/php7.2.1/conf/php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none)
inside /Applications/MAMP/bin/php/php7.2.1/conf/php.ini I can see
extension=mongodb.so and the version is 7.2.1
composer diagnose
may be helpful to determine the exact PHP binary used by Composer. It's quite possible that it's using macOS's default php
binary or an alternative version installed from Homebrew, each of which may have their own php.ini
file. Likewise, you should confirm the version of pecl
used to install the extension (e.g. which pecl
).
thanks again, you are right, I'm using default php. pecl version is:
PEAR Version: 1.10.5 PHP Version: 7.2.1 Zend Engine Version: 3.2.0
@Barno: Did you sort this out on your end, or is this still an outstanding problem?
Assuming your intention is to run the extension/library from MAMP's PHP environment, the take-away from https://github.com/mongodb/mongo-php-driver/issues/874#issuecomment-403911019 was:
pecl
command to install the extensionWe are closing this ticket as there was no follow up since our last question. Feel free to re-open with more information if we are mistaken.
sudo apt-get install php-mongodb
do php -m
and see if MongoDB extension is loaded.
If we used php7.3 at ubuntu 18.10 on need to this command:- Open Terminal and run it.
sudo apt-get install php7.3-mongodb
As of September 2019 sudo apt-get install php-mongodb
does not install a high enough version of the php-mongodb extension on Ubuntu. By using the pecl
install method, you will get the correct version.
If you don't have pecl installed:
sudo apt install php-pear
sudo apt install php-dev
Once pecl is installed:
sudo pecl install mongodb
Finally, to easily add the extension to php:
sudo phpenmod mongodb
@michaelphipps if you are having an issue, please consider opening a new issue instead of commenting on an old, unrelated issue. The version being installed depends heavily on the system you are using, which is why you need to include more information. The version being installed depends on your Ubuntu version (assuming you're not using a PPA):
Ubuntu Version | ext-mongodb version |
---|---|
Xenial (16.04 LTS) | 1.1.5 |
Bionic (18.04 LTS) | 1.3.4 |
Cosmic (18.10) | 1.5.2 |
Disco (19.04) | 1.5.3 |
Eoan (upcoming 19.10) | 1.5.5 |
If you are using ppa:ondrej/php
, it will install 1.5.5 on all supported platforms (16.04, 18.04, 19.04).
For any other versions in use or issues, please create a new issue and include necessary information so we can debug this. Thanks!
As of September 2019
sudo apt-get install php-mongodb
does not install a high enough version of the php-mongodb extension on Ubuntu. By using thepecl
install method, you will get the correct version.If you don't have pecl installed:
sudo apt install php-pear sudo apt install php-dev
Once pecl is installed:
sudo pecl install mongodb
Finally, to easily add the extension to php:
sudo phpenmod mongodb
Thanks @michaelphipps , this worked 👍
sudo add-apt-repository ppa:ondrej/php sudo apt-get install php-mongodb
macOS
sudo pecl install mongodb
Note: it will add extension automatically you need to remove existing extension line from php.ini if already exist
sudo apt-get install php7.3-mongodb
Worked for me in version 7.4 - sudo apt-get install php7.4-mongodb
I installed ext-mongodb
I have an issue with composer when I do composer install
My php Info (more details)
If I try to install mongodb with composer
composer require mongodb/mongodb
I have that errorIf I use ( and I don't want use this method )
I can see
But in This way I can't use some functionality, like aggregateCursor
or I can't use $m = new \MongoClient();
For connect to mongoDb I have to use
I Use Symfony, but I don't think that it's relevant