
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Utopia\Database\Database;
use Utopia\Cache\Cache;
use Utopia\Cache\Adapter\Memory;
use Utopia\Database\Adapter\Mongo;
use Utopia\Mongo\Client; // from utopia-php/mongo
use Swoole\Coroutine\Client as cli;
$dbHost = 'mongo';
$dbPort = 27017;
$dbUser = 'root';
$dbPass = 'password';
$dbName = 'dbName';
$mongoClient = new Client($dbName, $dbHost, $dbPort, $dbUser, $dbPass);
$cache = new Cache(new Memory()); // or use any cache adapter you wish
$database = new Database(new Mongo($client), $cache);
?>
While running this code I am getting 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(16): Utopia\Mongo\Client->__construct()
#1 {main}
thrown in /home/arnab/Desktop/php-utopia-database/vendor/utopia-php/mongo/src/Client.php on line 83
swoole is present in the vendor still I am getting this error

Maybe try reinstalling dependencies again?

Did thrice Same result

@Steven can you please tell me the package name I tried with utopia-swoole and ext-swoole but same results I am getting

You should run the code in the docker container. The swoole extension needs to be installed at the OS level rather than just from the vendor folder. The docker container that runs the tests has the swoole extension

Yes I figured that out by seeing the docker file And for working locally I installed the binaries of swoole globally using pecl. Yes it's working now Thanks 👍

[SOLVED] Swoole Coroutine Error
Recommended threads
- Query params are way too limiting in ter...
I was trying to list rows in a table that do not already exist in another table. I retrieved around 260 row IDs which are 13 characters in length each, and then...
- Relationship null, even when relationshi...
Hi Everyone, im experiencing issues with set relation data. When im setting the document id from the related database most of them seem fine, except one table. ...
- REQUEST FAILED IN MIGRATION
I was trying to moved my archived project to a self-host database . Though the Project is "read only" but there's a message that I can view and migrate data to...
