
I am working with the redis adaptor But I am facing some issues as I am totally new to php language
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
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:53
Stack 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 53

From what I can understand, you need to pass an instance of \Utopia\Mongo\Client
but you seem to be passing an instance of MongoDB\Client
.

After solving this error I am getting this error
PHP Fatal error: Uncaught Error: Class "Swoole\Coroutine\Client" not found in /home/arnab/Desktop/php-utopia-database/vendor/utopia-php/mongo/src/Client.php:83
Stack trace:
#0 /home/arnab/Desktop/php-utopia-database/test.php(17): Utopia\Mongo\Client->__construct()
#1 {main}
thrown in /home/arnab/Desktop/php-utopia-database/vendor/utopia-php/mongo/src/Client.php on line 83
But swoole is present in the vendor and if i am going to install it with composer I am getting the error package not exists

Are you executing stuff in the docker container?
Recommended threads
- Offline replication with RXDB
Hey there! Trying out apprwrite with rxdb for an offline focussed application. I cannot seem to find on how to set the permissions on a per document level?
- How to Fetch Item and Include the User/A...
A typical workflow with ORMs is to, for example, fetch an item from the DB and include the user who created it. How would I do that with AppWrite? Is that easil...
- Unable to add permission when creating a...
I am creating a collection from a cloud function using the Appwrite Dart server SDK, and I want to add permissions so it can be accessed by users. I added code ...
