Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer can't find mongodb extension #797

Closed
supaheckafresh opened this issue Mar 29, 2016 · 40 comments
Closed

Composer can't find mongodb extension #797

supaheckafresh opened this issue Mar 29, 2016 · 40 comments

Comments

@supaheckafresh
Copy link

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.

@Denys-Bushulyak
Copy link

Denys-Bushulyak commented May 13, 2016

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

@Denys-Bushulyak
Copy link

Denys-Bushulyak commented May 13, 2016

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

@Denys-Bushulyak
Copy link

Denys-Bushulyak commented May 13, 2016

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.

@Almas-Khan
Copy link

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

@supaheckafresh
Copy link
Author

@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.

@Denys-Bushulyak
Copy link

Denys-Bushulyak commented May 19, 2016

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

@alex-moreno
Copy link

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

@Criscros
Copy link

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

@Denys-Bushulyak
Copy link

@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

@Criscros
Copy link

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

@Denys-Bushulyak
Copy link

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

@Criscros
Copy link

Criscros commented Sep 22, 2016

thx

@thegregthomp
Copy link

I just needed to install the php driver for mongo

brew install php56-mongodb

@stea4lth
Copy link

stea4lth commented Nov 22, 2016

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

@Plutus038
Copy link

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

@ghost
Copy link

ghost commented Jan 6, 2017

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?

@ghost
Copy link

ghost commented Jan 6, 2017

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

@zaeem-bin-rehman
Copy link

zaeem-bin-rehman commented May 4, 2017

@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.

@lanka-senanayaka
Copy link

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

@miljanbrakocevic
Copy link

@Denys-Bushulyak Thank you :)

@chathurangat
Copy link

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

@MwirabuaTimothy
Copy link

MwirabuaTimothy commented Sep 8, 2017

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'

@sayan0020
Copy link

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

@pirmax
Copy link

pirmax commented Sep 14, 2017

Try

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

@sayan0020
Copy link

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

@jagadeshanh
Copy link

jagadeshanh commented Mar 22, 2018

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

@lexoyo
Copy link

lexoyo commented Oct 3, 2018

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

@mjniuz
Copy link

mjniuz commented Oct 27, 2018

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

@pcarrascom
Copy link

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

Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover
PHP Fatal error: Uncaught Error: Call to a member function connection() on null in C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1239
Stack trace:
#0 C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(1205): Illuminate\Database\Eloquent\Model::resolveConnection('mysql')
#1 C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(1035): Illuminate\Database\Eloquent\Model->getConnection()
#2 C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(952): Illuminate\Database\Eloquent\Model->newBaseQueryBuilder()
#3 C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(630): Illuminate\Database\Eloquent\Model->newModelQuery()
#4 C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel-admin-ext\reporter\src\Reporter.php(117): Illuminate\Database\Eloqu in C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 1239
PHP Fatal error: Uncaught Error: Call to a member function connection() on null in C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1239
Stack trace:
#0 C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(1205): Illuminate\Database\Eloquent\Model::resolveConnection('mysql')
#1 C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(1035): Illuminate\Database\Eloquent\Model->getConnection()
#2 C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(952): Illuminate\Database\Eloquent\Model->newBaseQueryBuilder()
#3 C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(630): Illuminate\Database\Eloquent\Model->newModelQuery()
#4 C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel-admin-ext\reporter\src\Reporter.php(117): Illuminate\Database\Eloqu in C:\Users\Proyectae01\Documents\GitHub\app\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 1239
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

@hamiozturk
Copy link

this is worked for me
#797 (comment)

@AymanElshehawy
Copy link

try this
composer install --ignore-platform-reqs

@bhavinjr
Copy link

bhavinjr commented Jun 7, 2019

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

@jeanlyj
Copy link

jeanlyj commented Sep 4, 2019

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!

@Ahmed-Aboud
Copy link

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

@Loetfi
Copy link

Loetfi commented Jan 22, 2020

@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 !

@Loetfi
Copy link

Loetfi commented Jan 22, 2020

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

composer update --ignore-platform-reqs

@briatek
Copy link

briatek commented Apr 9, 2020

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

Thank so much it work for me

@medaharrat
Copy link

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

This doesn't work on Laravel 7

@jokova91
Copy link

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

@Smolevich
Copy link
Contributor

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

This doesn't work on Laravel 7

Use alpha release v4

@mongodb mongodb locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests