0
votes

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

2 Answers

1
votes

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.

1
votes

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