I am having some trouble regarding PHP NATS. I am getting and printing msg body values. Everything is working fine. Just returning result is the problem. Here is the code
function connect(){
require_once __DIR__ . "/../../vendor/autoload.php";
$connectionOptions = new \Nats\ConnectionOptions();
$connectionOptions->setHost('localhost')->setPort(4222);
$c = new Nats\Connection($connectionOptions);
$c->connect();
$c->request('sayhello', 'Marty McFly', function ($response) {
echo $response->getBody();
return $response->getBody();
});
}
echo
is working and printing values, while return isn't returning anything if I use like this.
$res = connect():
print_r($res);