Skip to content

Instantly share code, notes, and snippets.

@benwaine
Last active August 29, 2015 14:20
Show Gist options
  • Save benwaine/f09c86e18370c7af5eb2 to your computer and use it in GitHub Desktop.
Save benwaine/f09c86e18370c7af5eb2 to your computer and use it in GitHub Desktop.
Capturing the response object in Guzzle 5
<?php
if (isset($this->username)) {
$args['user'] = $this->username;
}
$command = $this->client->getCommand($command, $args);
$command->getEmitter()->on('process', function(ProcessEvent $event) {
$this->response = $event->getResponse();
});
try {
$this->result = $this->client->execute($command);
} catch (\GuzzleHttp\Command\Exception\CommandClientException $e) {
// No Op - Response is saved above for interigation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment