connection = new \GuzzleHttp\Client([ 'base_uri' => $_ENV['MATTERBRIDGE_URL'], ]); } public function post($text, $username) { $response = $this->connection->request('POST', '/api/message', [ 'json' => [ 'gateway' => $_ENV['MATTERBRIDGE_GATEWAY'], 'text' => $text, 'username' => $username ], 'stream' => true, ]); $body = $response->getBody(); while (!$body->eof()) { echo $body->read(1024); } } }