Laravel with drivers of MongoDB - php

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

Related

Composer install mongo db version problem

I want to install a package using composer for my PHP project.
I tried this first:
composer require jenssegers/mongodb --ignore-platform-reqs
But it doesn't work with this method. Therefore, I removed the mongodb and after install again.
But it doesn't work this method.
composer install
Problem 1
- Installation request for mongodb/mongodb 1.4.2 -> satisfiable by mongodb/mongodb[1.4.2].
- mongodb/mongodb 1.4.2 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system.
Problem 2
- mongodb/mongodb 1.4.2 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system.
- jenssegers/mongodb v3.5.0 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.4.2].
- Installation request for jenssegers/mongodb v3.5.0 -> satisfiable by jenssegers/mongodb[v3.5.0].

Why does composer complain about the ext-mongo extension?

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.

PHP Mongodb installation issue on Linux Mint 17.3 Rosa

I am new to mongodb ,
I am following one tutorial and proceeding step by step , I installed mongodb and access it from shell .
Then I am doing php mongodb installation part .
I am doing it through composer , install composer and run the below command
composer require mongodb/mongodb
I am getting this below error output in my terminal .
$ composer require mongodb/mongodb
Using version ^1.4 for mongodb/mongodb
./composer.json has been created
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
- mongodb/mongodb 1.4.2 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system.
- mongodb/mongodb 1.4.1 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system.
- mongodb/mongodb 1.4.0 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system.
- Installation request for mongodb/mongodb ^1.4 -> satisfiable by mongodb/mongodb[1.4.0, 1.4.1, 1.4.2].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php5/cli/php.ini
- /etc/php5/cli/conf.d/05-opcache.ini
- /etc/php5/cli/conf.d/10-pdo.ini
- /etc/php5/cli/conf.d/20-json.ini
- /etc/php5/cli/conf.d/20-mysql.ini
- /etc/php5/cli/conf.d/20-mysqli.ini
- /etc/php5/cli/conf.d/20-pdo_mysql.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, deleting ./composer.json.
Here I added this things to my php.ini file and restarted the apache file.
extension = mongodb.so
PHP VERSION - PHP 5.5.9 AND Linux Mint 17.3 Rosa
Any suggestion?
where I am doing wrong

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 5 - Mongodb query builder installation

Every time when i am running "composer require jenssegers/mongodb ^3.0" this command in my command prompt. I am just getting below error can any one suggest. Thanks in advance.
Installation failed, reverting ./composer.json to its original content.
D:\XAMPP\htdocs\library>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 b
y mongodb/mongodb[1.0.0, 1.0.1].
- jenssegers/mongodb v3.0.1 requires mongodb/mongodb ^1.0.0 -> satisfiable b
y mongodb/mongodb[1.0.0, 1.0.1].
- jenssegers/mongodb v3.0.2 requires mongodb/mongodb ^1.0.0 -> satisfiable b
y mongodb/mongodb[1.0.0, 1.0.1].
- mongodb/mongodb 1.0.1 requires ext-mongodb ^1.1.0 -> the requested PHP ext
ension mongodb is missing from your system.
- mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP ext
ension mongodb is missing from your system.
- Installation request for jenssegers/mongodb ^3.0 -> satisfiable by jensseg
ers/mongodb[v3.0.0, v3.0.1, v3.0.2].
To enable extensions, verify that they are enabled in those .ini files:
- D:\XAMPP\php\php.ini
You can also run php --ini inside terminal to see which files are used by PH
P in CLI mode.
try this
composer require jenssegers/mongodb --ignore-platform-reqs

Categories