close

[Solved] $ Composer can’t find mongodb extension, required Mongodb extension

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error $ Composer can’t find mongodb extension, required Mongodb extension in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How $ Composer can’t find mongodb extension, required Mongodb extension Error Occurs?

Today I get the following error $ Composer can’t find mongodb extension, required Mongodb extension in php.

How To Solve $ Composer can’t find mongodb extension, required Mongodb extension Error ?

  1. How To Solve $ Composer can't find mongodb extension, required Mongodb extension Error ?

    To Solve $ Composer can't find mongodb extension, required Mongodb extension Error Install PHP extension by running this command on your terminal.

  2. $ Composer can't find mongodb extension, required Mongodb extension

    To Solve $ Composer can't find mongodb extension, required Mongodb extension Error Install PHP extension by running this command on your terminal.

Solution 1

This error will happen when using WAMP as there is an unique php.ini for WAMP and CMD.

So you might have added the mongo-ext to your WAMP php.ini and so it looks as though it is running and included in the enabled extension’s list. However, this is not available to the command line php.ini and also you need to confirm the CMD version of PHP you are running

  • You can confirm your CMD PHP version in the windows ENV variable “path”
  • If the CMD php version is not the same as the version you have included your mongo-ext, you will have to either install the mongo-ext into that version of PHP or change your path variable to point to the version of PHP you are currently using
  • Then ensure that the extension=php_mongodb is setup in both your WAMP and CMD version of php.ini

In order to confirm you have been successful your mongo-ext will show in your phpinfo() and if you run php -m on the CMD it will show in the rendered list

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

The above is not the correct way to do it, as it will create problems into the future with other packages, updates and/or installs.

Solution 2

Install PHP extension by running this command on your terminal.

sudo pecl install mongodb

At the end, you will see following information.

Build process completed successfully
Installing '/usr/local/Cellar/php/7.3.3/pecl/20180731/mongodb.so'
install ok: channel://pecl.php.net/mongodb-1.5.3
Extension mongodb enabled in php.ini

and then restart your PHP service.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment