Laravel-mongodb: Composer can't find mongodb extension

Created on 29 Mar 2016  Â·  40Comments  Â·  Source: jenssegers/laravel-mongodb

Hi - I'm running into essentially the same error as in issue #780 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 jenssegers/mongodb[v3.0.0, v3.0.1, v3.0.2].

  To enable extensions, verify that they are enabled in those .ini files:
    - C:\Program Files\PHP\v7.0\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.

I'm running Windows 10 and PHP 7. 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. If anyone can help me with this, I'd greatly appreciate it. Thanks.

Most helpful comment

composer require jenssegers/mongodb --ignore-platform-reqs
It solved my problem.

All 40 comments

Have the same problem but on Ubuntu (Homestead). At searching...

composer require jenssegers/mongodb --ignore-platform-reqs
It solved my problem.

Or another thing - pecl installing mongodb.so (if we talking about *nix OSes) but putting to mongo.ini:
extension=mongo.so
but have to
extension=mongodb.so
If you fix this string at:
/etc/php5/mods-available/mongo.ini
all have to be ok.
Please, ping me if it fix.

I've been banging my head all day and night today over this issue, thank you for the fix @Denys-Bushulyak!

@Denys-Bushulyak. Thank you, I did try your solution in a test project & it appears to work on Windows! As far as what I was working on before, I ended up installing the mongodb-php driver and jenssegers/mongodb inside of my vagrant machine & this worked great for my earlier project. Getting things set up inside of the vagrant box should have been more obvious to me before, but I'm quite new to Laravel.

Thank you all: @Siphion01 and @supaheckafresh. It's pleasure for me to be helpful.

@Denys-Bushulyak thanks, I was going through the xhgui install and having issues with mongo deps. That save my day.

@Denys-Bushulyak I'm running into MAMP but composer update no work and show the same error .... any help me please

@Criscros, try to look:

  1. php -m to see than extenstsion is installed
  2. php -i | grep mongo will show you where mongodb ini file located
  3. change extension=mongo.so if exists to extension=mongodb.so

i can see where is ini file @Denys-Bushulyak
captura de pantalla 2016-09-21 a las 9 19 25 a m

Sorry, I said wrong way. it 's your host spec. We need MAMP.

thx

I just needed to install the php driver for mongo

brew install php56-mongodb

This worked for me...

sudo pecl install mongodb
sudo nano /etc/php5/mods-available/mongodb.ini insert in file extension=mongodb.so
sudo ln -sv /etc/php5/mods-available/mongodb.ini /etc/php5/apache2/conf.d/20-mongodb.ini
sudo ln -sv /etc/php5/mods-available/mongodb.ini /etc/php5/cli/conf.d/20-mongodb.ini
sudo service apache2 restart
composer require jenssegers/mongodb

Hi,
ln: failed to create symbolic link ‘/etc/php5/cli/conf.d/20-mongodb.ini’: File exists
I can't able to create symbolic link

I already install the adapter and it connects well using homebrew on my OSX El Capitan..
when i called using mongod and mongo on the terminal it works

But when i install it using composer require jenssegers/mongodb, it throws the error like the first post on this thread..

So i use Denys-Bushulyak method and it works on the installation..my question is..is anyone working around with the complete instalation on OSX?if one doesn't use the package requirements..is it working too?

Ok after searching me and my coleague manage to figure some of the process and successfully install it on the el-capitan.. At first we need to compile manually and install dependencies(such as autoconf) even the openssl as well(relink and all) .. it works well now.

These link also helps greately for anyone having trouble on updating and symlink openssl
http://apple.stackexchange.com/questions/244058/homebrew-trouble-upgrading-openssl

@Denys-Bushulyak can you please help me resolve my issue. here is the detail.

Installed mongo via "mongodb/mongodb": "^1.0.0" in the composer file.

When installing mongo db using (I'm using nginx)
sudo pecl install mongodb
sometimes it gives phpize error so you need to run
apt-get install php7.0-dev (or php7.1-dev)
after that it will install mongodb successfully

don't forget to run
sudo service nginx restart

sudo /etc/init.d/php7.0-fpm restart

@Denys-Bushulyak Thank you :)

@Denys-Bushulyak Thank you very much! it worked fine!

Try installing the mongodb extension using homebrew.
Change this commands to your php version.

$ brew tap homebrew/php
$ brew install php56-mongodb

Then link it to your php.ini

extension='/usr/local/opt/php56-mongodb/mongodb.so'

I'm using php 5.6, so it helped me

sudo apt-get install -y php-pear php5.6-dev
sudo pecl install mongo

sudo sh -c "echo 'extension=mongo.so' > /etc/php/5.6/mods-available/mongo.ini"
sudo ln -s /etc/php/5.6/mods-available/mongo.ini /etc/php/5.6/apache2/conf.d/mongo.ini

sudo service apache2 restart

Try

composer require jenssegers/laravel-mongodb --ignore-platform-reqs

i've, but it didn't solve my problem

I executed following commands in order (ubuntu 16.04) (php 7.2)

sudo apt-get install php-mongodb

composer require mongodb/mongodb

composer require jenssegers/mongodb

what I did in fedora was sudo dnf install php-mongodb

Make sure mongodb version/type is correct
I use this

sudo yum install -y openssl-devel
sudo yum install pecl
sudo yum install gcc
sudo pecl install mongodb

Hi, every idea will be tested here...
I tried with "composer require jenssegers/mongodb --ignore-platform-reqs" and get this:

IlluminateFoundationComposerScripts::postAutoloadDump
@php artisan package:discover
PHP Fatal error: Uncaught Error: Call to a member function connection() on null in C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php:1239
Stack trace:

0 C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php(1205): IlluminateDatabaseEloquentModel::resolveConnection('mysql')

1 C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php(1035): IlluminateDatabaseEloquentModel->getConnection()

2 C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php(952): IlluminateDatabaseEloquentModel->newBaseQueryBuilder()

3 C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php(630): IlluminateDatabaseEloquentModel->newModelQuery()

4 C:UsersProyectae01DocumentsGitHubappvendorlaravel-admin-extreportersrcReporter.php(117): IlluminateDatabaseEloqu in C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php on line 1239

PHP Fatal error: Uncaught Error: Call to a member function connection() on null in C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php:1239
Stack trace:

0 C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php(1205): IlluminateDatabaseEloquentModel::resolveConnection('mysql')

1 C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php(1035): IlluminateDatabaseEloquentModel->getConnection()

2 C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php(952): IlluminateDatabaseEloquentModel->newBaseQueryBuilder()

3 C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php(630): IlluminateDatabaseEloquentModel->newModelQuery()

4 C:UsersProyectae01DocumentsGitHubappvendorlaravel-admin-extreportersrcReporter.php(117): IlluminateDatabaseEloqu in C:UsersProyectae01DocumentsGitHubappvendorlaravelframeworksrcIlluminateDatabaseEloquentModel.php on line 1239

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

try this
composer install --ignore-platform-reqs

This is worked for me

sudo pecl install mongodb

After installation, you may be seen this

Extension mongodb enabled in php.ini

then you need to
composer install

Thanks @stea4lth

Cool! @Denys-Bushulyak
I have to spend a lot of time to search for a solution, but your's is the final.
Thanks a lot!

for windows https://pecl.php.net/package/mongodb download the DLL and place it in xampp/php/ext folder and open php.ini and add extension=php_mongodb.dll

@Criscros, try to look:

1. `php -m` to see than extenstsion is installed

2. `php -i | grep mongo` will show you where mongodb ini file located

3. change `extension=mongo.so` if exists to `extension=mongodb.so`

thanks !

composer require jenssegers/mongodb --ignore-platform-reqs
It solved my problem.

composer update --ignore-platform-reqs

composer require jenssegers/mongodb --ignore-platform-reqs
It solved my problem.

Thank so much it work for me

composer require jenssegers/mongodb --ignore-platform-reqs
It solved my problem.

This doesn't work on Laravel 7

@medaharrat Maybe check out the compatibility of laravel & jenssegers versions https://github.com/jenssegers/laravel-mongodb#laravel-version-compatibility

composer require jenssegers/mongodb --ignore-platform-reqs
It solved my problem.

This doesn't work on Laravel 7

Use alpha release v4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sanjay1688 picture sanjay1688  Â·  3Comments

lgt picture lgt  Â·  3Comments

bastiendonjon picture bastiendonjon  Â·  3Comments

tomartailored picture tomartailored  Â·  3Comments

BlakeGardner picture BlakeGardner  Â·  3Comments