Back

[SOLVED] Swoole Coroutine Error

  • 0
  • Databases
ArnabChatterjee20k|Mentor
8 Oct, 2023, 14:17
TypeScript
<?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

TypeScript
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

TL;DR
Solution: The user was experiencing an error with the Swoole Coroutine. They found that installing the Swoole binaries globally using pecl solved the issue. However, when running the code in a Docker container, they encountered the same error again. Another user suggested that the swoole extension needs to be installed at the OS level and mentioned that the Docker container running the tests has the swoole extension. The user asked for the package name, but did not receive a response. TL;DR: User solved the Swoole Coroutine error by installing the binaries globally using pecl. However, when running the code in a Docker container,
Drake
9 Oct, 2023, 05:37

Maybe try reinstalling dependencies again?

ArnabChatterjee20k|Mentor
9 Oct, 2023, 07:36

Did thrice Same result

ArnabChatterjee20k|Mentor
9 Oct, 2023, 09:58

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

Drake
15 Oct, 2023, 03:23

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

ArnabChatterjee20k|Mentor
15 Oct, 2023, 03:25

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 👍

Drake
15 Oct, 2023, 04:10

[SOLVED] Swoole Coroutine Error

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more