I am trying to install Doctrine MongoDB ODM module through composer with Zend Framework 2 on my local machine but I keep getting an error stating that PHP extension mango is missing from my computer. I am working on a Windows 7 x64 with WAMP 2.2 installed. I originally installed the 1.3.1 mongodb php driver. However, I found out that this driver isn't supported by MongoDB ODM yet so I downgraded to 1.2.12. After I tried the installation again I kept getting the same error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- doctrine/mongodb 1.0.0-BETA3 requires ext-mongo >=1.3.1,<1.4-dev -> the re
quested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0-BETA2 requires ext-mongo >=1.2.12,<1.3-dev -> the r
equested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0-BETA1 requires ext-mongo * -> the requested PHP ext
ension mongo is missing from your system.
- doctrine/doctrine-mongo-odm-module dev-master requires doctrine/mongodb-od
m 1.* -> satisfiable by doctrine/mongodb-odm 1.0.0-BETA4, doctrine/mongodb-odm 1
.0.0-BETA5, doctrine/mongodb-odm 1.0.0-BETA6.
- doctrine/mongodb-odm 1.0.0-BETA4 requires doctrine/mongodb 1.0.0-BETA1 ->
satisfiable by doctrine/mongodb 1.0.0-BETA1.
- doctrine/mongodb-odm 1.0.0-BETA5 requires doctrine/mongodb 1.0.0-BETA1 ->
satisfiable by doctrine/mongodb 1.0.0-BETA1.
- doctrine/mongodb-odm 1.0.0-BETA6 requires doctrine/mongodb >=1.0.0-beta1,<
1.1-dev -> satisfiable by doctrine/mongodb 1.0.0-BETA1, doctrine/mongodb 1.0.0-B
ETA2, doctrine/mongodb 1.0.0-BETA3.
- Installation request for doctrine/doctrine-mongo-odm-module dev-master ->
satisfiable by doctrine/doctrine-mongo-odm-module dev-master.
I checked phpinfo and MongoDB shows up there. I was successfully able to connect to a local database with a simple php script without doctrine. So I know Wamp and mongoDB are working fine. the problem is when integrating doctrine. Any ideas or suggestions troubleshooting this is greatly appreciated. thanks
I found out that Composer runs on PHP-CLI and in the case of wamp, there are two php.ini files:
one in the php folder and one in apache folder. the one in the apache directory is used with the webserver
which is what is edited when accessing php.ini from wamp. I usually edit my php.ini from wamp so in effect
I end up editing php.ini in apache.
composer in the other had is accessing the php.ini located in the php directory.
this php.ini does not know about the mongo extension, hence the error about missing extension.
As a solution to the problem, I added the extension of mongodb in the php.ini located in the php directory.
Restarted wamp and ran composer once more. The outcome, the module installed succesfully!.
You have to install mongo php extension
https://github.com/mongodb/mongo-php-driver/downloads
Related
When I try to install doctrine/mongodb-odm-bundle and doctrine/mongodb with composer it throws an error.
composer require doctrine/mongodb-odm-bundle doctrine/mongodb
Using version ^3.5 for doctrine/mongodb-odm-bundle
Using version ^1.6 for doctrine/mongodb
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- doctrine/mongodb 1.6.3 requires ext-mongo ^1.6.7 -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.6.2 requires ext-mongo ^1.6.7 -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.6.1 requires ext-mongo ^1.6.7 -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.6.0 requires ext-mongo ^1.6.7 -> the requested PHP extension mongo is missing from your system.
- Installation request for doctrine/mongodb ^1.6 -> satisfiable by doctrine/mongodb[1.6.0, 1.6.1, 1.6.2, 1.6.3].
To enable extensions, verify that they are enabled in your .ini files:
-
- /usr/local/etc/php/conf.d/docker-php-ext-mongodb.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-soap.ini
- /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
- /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, reverting ./composer.json to its original content.
I was suprised to see this error message because I did install Mongodb with pecl and enabled it with an ini file.
RUN pecl install mongodb \
&& docker-php-ext-enable mongodb
Does anyone knows how to solve this?
I figured that by adding a provide section with the ext-mongo to the composer.json file the issue was resolved
"provide" : {
"ext-mongo": "*"
}
It appears to completely ignore the php extension.
When executing composer require jenssegers/mongodb:
$ composer require jenssegers/mongodb
Using version ^3.0 for jenssegers/mongodb
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- jenssegers/mongodb v3.0.0 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1].
- jenssegers/mongodb v3.0.1 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1].
- jenssegers/mongodb v3.0.2 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1].
- mongodb/mongodb 1.0.1 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
- mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
- Installation request for jenssegers/mongodb ^3.0 -> satisfiable by
ers/mongodb[v3.0.0, v3.0.1, v3.0.2].
To enable extensions, verify that they are enabled in those .ini files
- C:\wamp\bin\php\php5.5.12\php.ini
You can also run php --ini inside terminal to see which files are us
P in CLI mode.
Installation failed, reverting ./composer.json to its original content.
I am running Windows 7 and PHP 5.5.12 use mongodb 3.2 . I installed the mongodb extension (php_mongodb.dll in PHP ext/ folder), and I've updated php.ini with extension=php_mongodb.dll. Not sure what I've missed
There are two kinds of drivers available at pecl
You need to install the mongoDB database driver. As you explained it looks like you have installed the mongoDB driver for PHP which is not correct
and you have to add php_mongo.dll in your php.ini
extension=php_mongo.dll
as explained here
get the proper DLL from here
You will get something like this in your phpinfo();
I hope this helps. Thanks,
I've followed the official documentation
when I run composer update I have this error :
Your requirements could not be resolved to an installable set of packages.
Problem 1
- doctrine/mongodb 1.0.4 requires ext-mongo >=1.2.12,<1.6-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.3 requires ext-mongo >=1.2.12,<1.5-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.2 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.1 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb-odm 1.0.0-BETA9 requires doctrine/mongodb 1.0.* -> satisfiable by doctrine/mongodb[1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4].
- Installation request for doctrine/mongodb-odm 1.0.0-BETA9 -> satisfiable by doctrine/mongodb-odm[1.0.0-BETA9].
When I run php -m I can't find mongo extension , but the server is running and I can use Mongo in PHP, does anyone know what should the problem be ?
I doubt that the doctrine can't find the mongo extension..
thanks !
I fixed it !
As expected, it was because of the extension so here are the steps to take if you face the same problem as me : the requested PHP extension mongo is missing from your system.
run the command : php --ini, you will see all the configuration files parsed! For me , I am using PHP-fpm , I thought the only php.ini file needed was inside fpm folder, but I was wrong there was a php.ini file inside CLI folder and it's this folder that tells the server which modules are loaded , and it's exactly the same file that doctrine reads the extensions from.
Open CLI/php.ini and add this line in the end extension=mongo.so.
Restart PHP : service php5-fpm restart
That's it!
for OSX:
brew install php56-mongo
if it errors out: read the error message carefully and follow it to rerun the command.
source:
http://php.net/manual/en/mongo.installation.php#mongo.installation.osx
Linux
To install PHP's MongoDB extension, run:
sudo apt-get install php-mongo
See also: Easiest way to install Mongodb PHP extension in Ubuntu 13.10 (saucy)?
Trying to install doctrine/mongodb-odm via Composer I get this:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- doctrine/mongodb 1.0.x-dev requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.2 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.1 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0-BETA3 requires ext-mongo >=1.3.1,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0-BETA2 requires ext-mongo >=1.2.12,<1.3-dev -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0-BETA1 requires ext-mongo * -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.0.0 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
- Installation request for doctrine/mongodb 1.0.*#dev -> satisfiable by doctrine/mongodb 1.0.0, doctrine/mongodb 1.0.0-BETA1, doctrine/mongodb 1.0.0-BETA2, doctrine/mongodb 1.0.0-BETA3, doctrine/mongodb 1.0.1, doctrine/mongodb 1.0.2, doctrine/mongodb 1.0.x-dev.
However php -m has:
[PHP Modules]
...
mongo
...
And composer.phar show --platform has:
...
ext-mongo 1.3.5 The mongo PHP extension
...
Any ideas? The extension is definitely installed correctly, and Composer even lists it. The version (>=1.2.12,<1.4-dev) meets the requirements as well.
Turns out this was the fault of the Sublime Text 2 Composer plugin. If I run Coomposer via Terminal it's fine. Why it doesn't work in ST2 is a bit of a mystery though, as far as I can tell it's executing exactly the same command: /bin/composer.phar update -n -v.
If you loaded Mongo into an instance of PHP installed via WAMPSERVER, a likely cause for this issue is that only one of the 2 php.ini files was modified path\to\wamp\bin\php\php5\php.ini. If you add the extension=php_mongo.dll to the path\to\wamp\bin\apache\apche2\bin\php.ini you should be able to execute php with mongo functions from the command line or editer cli tools.
If you run into composer error:
doctrine/mongodb 1.0.x-dev requires ext-mongo >=1.2.12,<1.5-dev -> the requested PHP extension mongo is missing from your system
then it's another indicator you need to update the apache2x\bin\php.ini file
When I run this command composer require google/apiclient:"^2.0" I get these error messages:
Problem 1
mongodb/mongodb 1.5.1 requires ext-mongodb ^1.6 -> the requested PHP extension mongodb is missing from your system.
mongodb/mongodb 1.5.1 requires ext-mongodb ^1.6 -> the requested PHP
extension mongodb is missing from your system.
mongodb/mongodb 1.5.1 requires ext-mongodb ^1.6 -> the requested PHP
extension mongodb is missing from your system.
Installation request for mongodb/mongodb (locked at 1.5.1, required as
^1.5) -> satisfiable by mongodb/mongodb[1.5.1].
To enable extensions, verify that they are enabled in your .ini files:
C:\PHP7\php.ini
You can also run php --ini inside terminal to see which files are used by PHP
in CLI mode.
Can someone explain to me why this is happening as I am quite new to Php & composer ?
It looks like the mongodb extension is causing the issues. I dont need mongodb anymore and I deleted the ;extension=php_mongodb.dll lines in my Php.ini files
You still have mongodb referenced in either your composer.json, or composer.lock. Double-check your composer.json, delete your composer.lock, and then run your composer command again.