Why does composer complain about the ext-mongo extension? - php

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.

Related

Updating Composer in Digital Ocean Ubuntu via Terminal errors

I am using a mac and in the command line, I am logged into the server, and want to install composer however I get a number of issues (see below). I don't need PHP unit and so I have also tried composer install --no-dev but the same errors are appearing. Any idea or solution?
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for tijsverkoyen/css-to-inline-styles 2.2.2 -> satisfiable by tijsverkoyen/css-to-inline-styles[2.2.2].
- tijsverkoyen/css-to-inline-styles 2.2.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 2
- tijsverkoyen/css-to-inline-styles 2.2.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- laravel/framework v7.3.0 requires tijsverkoyen/css-to-inline-styles ^2.2.2 -> satisfiable by tijsverkoyen/css-to-inline-styles[2.2.2].
- Installation request for laravel/framework v7.3.0 -> satisfiable by laravel/framework[v7.3.0].
I also tried to install the tijsverkoyen via Sudo and receive another list of issues
Problem 1
- phpunit/phpunit 8.5.x-dev requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.5.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.5.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.5.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 8.5.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- Installation request for phpunit/phpunit ^8.5 -> satisfiable by phpunit/phpunit[8.5.0, 8.5.1, 8.5.2, 8.5.3, 8.5.x-dev].
The error message says you're missing the PHP extension ext-dom.
You'll need to install it by running sudo apt install php-xml.

Composer can't find mongodb 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,

Laravel with drivers of MongoDB

I'm new using MongoDB in laravel, I want to use laravel 4.2 with MongoDB but I have this problem:
> C:\xampp\htdocs\laravel-mongo>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 has the wrong version (1.0.0) installed.
- mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb has the wrong version (1.0.0) installed.
- Installation request for jenssegers/mongodb ^3.0 -> satisfiable by jenssegers/mongodb[v3.0.0, v3.0.1, v3.0.2].
To enable extensions, verify that they are enabled in those .ini files:
- C:\xampp\php\php.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.
For Laravel 4.2 you would need 2.0.x version of the package
composer require jenssegers/mongodb ^2.0
When you don't specify the version composer grabs the latest stable release by default, which currently happens to be v3.0.2.
This happened to me (for Lumen 5) due to an old mongo installation.
From http://php.net/manual/en/class.mongoclient.php:
Warning: This extension that defines this class is deprecated. Instead,
the MongoDB extension should be used.
Following next steps I was able to get jenssegers/mongodb properly working:
sudo apt-get install php5-dev
sudo pecl install mongodb
Then add to /etc/php5/cli/php.ini or similar:
extension=mongodb.so
And then install the driver
composer require jenssegers/mongodb
ref: http://haafiz.me/development/installing-mongodb-driver-mongoclient-for-php-on-ubuntu

Can't install mongodb doctrine in symfony2 with composer

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)?

Can't install doctrine/mongodb-odm using Composer

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

Categories