PHP Fatal error: Uncaught Error: Class ‘Mongo’ not found

  mongodb, php

I’ve been trying to install the MongoDB extension for PHP for a while now with no luck. I followed the standard steps:

  • Installed the driver via Pecl
  • Added it to my PHP.ini file (both CLI and Apache2)
  • Restarted Apache2

Yet, my code believes it does not exist:

$conn = new Mongo($_ENV["DB"]);
$db = $conn->test;
PHP Fatal error:  Uncaught Error: Class 'Mongo' not found in /var/www/ag/API/index.php:22nStack trace:n#0 {main}n  thrown in /var/www/ag/API/index.php on line 22

Any ideas what I am doing wrong? I am using PHP 7.3 and Apache 2.4.38 on Debian

I saw a question like this for Windows, but it was of no help to me.

Source: Ask PHP

LEAVE A COMMENT