Arnab20k(Gravdestroyer)Original post
Rank 1: Thread
I am working with the redis adaptor
But I am facing some issues as I am totally new to php language
PHP
require_once __DIR__ . '/database/vendor/autoload.php';use Utopia\Database\Database;use Utopia\Cache\Cache;use Utopia\Cache\Adapter\Memory;use Utopia\Database\Adapter\Mongo;use MongoDB\Client; // Use MongoDB\Client for MongoDB connection
$dbHost = 'mongo';$dbPort = 27017;$dbUser = 'root';$dbPass = 'password';$dbName = 'dbName';
$mongoClient = new Client("mongodb://localhost:27017");
$cache = new Cache(new Memory()); // or use any cache adapter you wish
$database = new Database(new Mongo($mongoClient, $dbName), $cache);echo $database;But I am getting this issue
Bash
PHP Fatal error: Uncaught TypeError: Utopia\Database\Adapter\Mongo::__construct(): Argument #1 ($client) must be of type Utopia\Mongo\Client, MongoDB\Client given, called in /home/arnab/Desktop/test.php on line 19 and defined in /home/arnab/Desktop/database/src/Database/Adapter/Mongo.php:53Stack trace:#0 /home/arnab/Desktop/test.php(19): Utopia\Database\Adapter\Mongo->__construct()#1 {main} thrown in /home/arnab/Desktop/database/src/Database/Adapter/Mongo.php on line 53Summary
The user is encountering an error related to the Swoole\Coroutine\Client class not being found. They mentioned that Swoole is present in the vendor, but they cannot install it using composer as they receive an error stating that the package does not exist.
In addition, the user is new to PHP and is facing issues with the redis adapter. They provided a code snippet where they are trying to connect to a MongoDB instance using the `MongoDB\Client` class. However, they are getting a fatal error stating that the argument passed to the constructor of `Utopia\Database\Adapter\Mongo` must be of type `Utop