I am trying to connect with mongodb with php 7.3 using codeIgniter. I have installed mongodb server
C:\Program Files\MongoDB\Server\4.4\bin>mongo.exe
MongoDB shell version v4.4.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("6cef5e22-fa00-40f9-8f3d-09f03d6bb974") }
MongoDB server version: 4.4.8
---
The server generated these startup warnings when booting:
2021-08-16T10:29:40.356+05:30: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
---
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
to test the mongodb is working or not i have write the code
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
echo "hello";
$connection = new MongoDB\Driver\Manager("mongodb://localhost:27017");
var_dump($connection);
}
}
The output is
An Error Was Encountered
The MongoDB PECL extension has not been installed or enabled
I have added the dll file to ext folder & added the extension in php.ini extension=php_mongodb.dll