1

I'm stuck with a problem of MongoDb installation. I'm working with Symfony 6 and PHP 8.1, and i would like integrate in my application mongoDB. I've downloaded the mongoDB image on Docker, and all is working.

The problem

Now, i need to use doctrine for MongoDB. So, follow the documentation , i run composer require doctrine/mongodb-odm-bundle and also composer require doctrine/mongodb-odm . For the first command, i get the following errors:

Problem 1 - doctrine/mongodb-odm-bundle[4.3.0, ..., 4.3.1] require doctrine/persistence ^1.3.6|^2.0 -> found doctrine/persistence[1.3.6, 1.3.7, 1.3.8, 2.0.0, ..., 2.5.7] but it conflicts with your root composer.json require (^3.1).
- doctrine/mongodb-odm-bundle[4.4.0, ..., 4.5.2] require ext-mongodb ^1.5 -> it is missing from your system. Install or enable PHP's mongodb extension. - Root composer.json requires doctrine/mongodb-odm-bundle ^4.3 -> satisfiable by doctrine/mongodb-odm-bundle[4.3.0, ..., 4.5.2]. To enable extensions, verify that they are enabled in your .ini files: - C:\xampp\php8\php.ini You can also run php --ini in a terminal to see which files are used by PHP in CLI mode. Alternatively, you can run Composer with --ignore-platform-req=ext-mongodb to temporarily ignore these required extensions.

And for the second one:

You are running Composer with SSL/TLS protection disabled. Using version ^1.0 for doctrine/mongodb-odm Running composer update doctrine/mongodb-odm Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages. Problem 1 - doctrine/mongodb-odm[1.0.0, ..., 1.0.8] require symfony/console ~2.3|~3.0 -> found symfony/console[v2.3.0, ..., v2.8.52, v3.0.0, ..., v3.4.47] but it conflicts with your root composer.json require (6.2.*). - doctrine/mongodb-odm[1.1.0, ..., 1.3.7] require php ^5.6 || ^7.0 -> your php version (8.1.11) does not satisfy that requirement. - Root composer.json requires doctrine/mongodb-odm ^1.0 -> satisfiable by doctrine/mongodb-odm[1.0.0, ..., 1.3.7].

As you can see, in the first error message he trying to say me that i have some packages not compatible with the installation of mongo's extension. In the second, with the default command installation, he's trying to install 1.0 version instead 2.4.*!

What i've tried?

So, i tried to 'force' the installation. I've insert "doctrine/mongodb-odm": "^2.4.0" in the composer.json , followed by composer update doctrine/mongodb-odm and i still get the error:

Problem 1- Root composer.json requires doctrine/mongodb-odm ^2.4.0 -> satisfiable by doctrine/mongodb-odm[2.4.0, 2.4.1, 2.4.2, 2.4.3]. - doctrine/mongodb-odm[2.4.0, ..., 2.4.3] require ext-mongodb ^1.5 -> it is missing from your system. Install or enable PHP's mongodb extension.

What i suppose?

Maybe can be the extension of mongo DB in the php.ini file, but i ve installed mongoDB also on windows and added the extension in the php.ini file, but nothing is changed.

Any ideas? Thx

Zed93
  • 39
  • 5
  • Please add all error messages in text form, along wiht your attempts to resolve the problem – Nico Haase Feb 14 '23 at 09:30
  • Also, how did you try to install the extension? Installing it on Windows won't make it available to any Docker image – Nico Haase Feb 14 '23 at 09:31
  • @NicoHaase Done. Yes, but when i saw the message related to php.ini, i thought that can be this the problem. I tried with PECL https://github.com/mongodb/mongo-php-driver/releases/ – Zed93 Feb 14 '23 at 09:35
  • Please share how you tried to enable the extension to the Docker container – Nico Haase Feb 14 '23 at 09:46
  • I have php in local, on Docker i have just the Mongo image. So i don't have PHP on docker, how can i enable the extension on it? – Zed93 Feb 14 '23 at 09:52
  • https://stackoverflow.com/questions/47272688/mongodb-mongodb-1-2-0-requires-ext-mongodb-1-3-0-the-requested-php-extensi could help, or https://stackoverflow.com/questions/49597994/installing-mongodb-driver-php-7-2-3 – Nico Haase Feb 14 '23 at 10:05

1 Answers1

0

The problem was the MongoDB drivers. So, what i did is:

  • Download the MongoDB package with DLL included.
  • Copy the DLL extension of Mongo inside php/ext folder
  • execute pecl install mongodb

For the next, follow this Documentation.

Zed93
  • 39
  • 5