The error message mongodb/mongodb 1.2.0 requires ext-mongodb ^1.3.0 is often the first hurdle when attempting to use the modern MongoDB PHP driver on legacy systems. It signals a version mismatch: the Composer package you are trying to install expects a specific, newer C-extension that your system simply does not have installed or loaded.
If you are working with an older environment like Debian Jessie with PHP 5.6.30, this incompatibility is expected. The ext-mongodb extension bundled with those packages often pre-dates the driver class structure required by version 1.2.0 of the Composer package. While some users suggest using the --ignore-platform-reqs flag to bypass this check during installation, that approach only gets you halfway there. Ignoring the requirement allows Composer to download the PHP files, but the underlying C-extension is still missing from your system's library path.
When you subsequently try to instantiate a client or run code like $client = new MongoDB\Client(...), you will encounter a Fatal error: Class 'MongoDB\Driver\Manager' not found. This occurs because the PHP runtime cannot resolve the native extension that the Composer package relies on to communicate with the database server. The fact that your Python connection works confirms your database credentials and network reachability are fine; the issue is strictly within the PHP environment.
To resolve this on legacy systems, you must manually install the correct C-extension before attempting to use the Composer package. The manual installation process described in the official PHP documentation is the standard path for these older versions. You need to locate the compiled .so file and ensure it is explicitly loaded in your configuration.
For example, if your extension_dir points to /usr/lib/php5/20131226, you must add the following line directly after the "Dynamic Extensions" directive in /etc/php5/apache2/php.ini:
extension=/usr/lib/php5/20131226/mongo.so
However, simply adding this line is not enough if the version of mongo.so currently on your system corresponds to an older API that conflicts with the new driver. In many cases involving PHP 5.6, the legacy mongo extension and the new mongodb extension are mutually exclusive in terms of naming but distinct in functionality. You may need to locate a specific build of the ext-mongodb library compatible with your exact PHP version and architecture (e.g., php5.6-mongodb_1.3.0-1_amd64.deb on Debian).
Once the correct extension is installed and loaded, you can retry the Composer command:
php composer.phar require mongodb/mongodb
If the --ignore-platform-reqs flag was necessary to get past the initial validation, ensure that your manually installed extension satisfies the version constraint specified in the error message (^1.3.0). If you continue to face class not found errors after installation, verify the extension is actually loaded by running php -i | grep mongodb. You should see a line confirming the extension is active and another listing the path to the driver library files.
For modern Laravel applications or projects requiring strict dependency management, upgrading your PHP version to 7.4 or higher is strongly recommended. Newer PHP versions come with up-to-date MongoDB extensions that seamlessly integrate with Composer packages without needing manual .so file manipulation. If you are maintaining a legacy application on an older stack, ensure you are using the specific legacy driver package (mongodb/mongodb-legacy) if the modern driver does not align with your existing codebase requirements.