2017 © Pedro Peláez
 

library guzzle-commands

PHP 5.3-compatible fork of guzzle/command

image

ehough/guzzle-commands

PHP 5.3-compatible fork of guzzle/command

  • Friday, December 23, 2016
  • by ehough
  • Repository
  • 1 Watchers
  • 1 Stars
  • 46 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 17 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

ehough/guzzle-commands

Build Status Latest Stable Version License, (*1)

A PHP 5.3-compatible fork of Guzzle Commands., (*2)

Why?

Sadly, 60% of all PHP web servers still run PHP 5.4 and lower, but Guzzle Commands needs PHP 5.5 or higher. This fork makes Guzzle Commands compatible with PHP 5.3.29 through 7.1., (*3)

How to Use This Fork

Usage is identical to guzzle/command, except that the code in this library is namespaced under Hough\Guzzle\Command instead of GuzzleHttp\Command., (*4)


This library uses Guzzle (ehough/guzzle, version 6.x) and provides the foundations to create fully-featured web service clients by abstracting Guzzle HTTP requests and responses into higher-level commands and results. A middleware system, analogous to — but separate from — the one in the HTTP layer may be used to customize client behavior when preparing commands into requests and processing responses into results., (*5)

Commands

Key-value pair objects representing an operation of a web service. Commands have a name and a set of parameters., (*6)

Results

Key-value pair objects representing the processed result of executing an operation of a web service., (*7)

Service Clients

Service Clients are web service clients that implement the Hough\Guzzle\Command\ServiceClientInterface and use an underlying Guzzle HTTP client (GuzzleHttp\Client) to communicate with the service. Service clients create and execute commands (Hough\Guzzle\Command\CommandInterface), which encapsulate operations within the web service, including the operation name and parameters. This library provides a generic implementation of a service client: the Hough\Guzzle\Command\ServiceClient class., (*8)

Instantiating a Service Client

@TODO Add documentation, (*9)

  • ServiceClient's constructor
  • Transformer functions ($commandToRequestTransformer and $responseToResultTransformer)
  • The HandlerStack

Executing Commands

Service clients create command objects using the getCommand() method., (*10)

$commandName = 'foo';
$arguments = ['baz' => 'bar'];
$command = $client->getCommand($commandName, $arguments);

After creating a command, you may execute the command using the execute() method of the client., (*11)

$result = $client->execute($command);

The result of executing a command will be a Hough\Guzzle\Command\ResultInterface object. Result objects are ArrayAccess-ible and contain the data parsed from HTTP response., (*12)

Service clients have magic methods that act as shortcuts to executing commands by name without having to create the Command object in a separate step before executing it., (*13)

$result = $client->foo(['baz' => 'bar']);

Asynchronous Commands

@TODO Add documentation, (*14)

  • -Async suffix for client methods
  • Promises
// Create and execute an asynchronous command.
$command = $command = $client->getCommand('foo', ['baz' => 'bar']);
$promise = $client->executeAsync($command);

// Use asynchronous commands with magic methods.
$promise = $client->fooAsync(['baz' => 'bar']);

@TODO Add documentation, (*15)

  • wait()-ing on promises.
$result = $promise->wait();

echo $result['fizz']; //> 'buzz' 

Concurrent Requests

@TODO Add documentation, (*16)

  • executeAll()
  • executeAllAsync().
  • Options (fulfilled, rejected, concurrency)

Middleware: Extending the Client

Middleware can be added to the service client or underlying HTTP client to implement additional behavior and customize the Command-to-Result and Request-to-Response lifecycles, respectively., (*17)

Todo

  • Middleware system and command vs request layers
  • The HandlerStack

The Versions

23/12 2016

dev-develop

dev-develop

PHP 5.3-compatible fork of guzzle/command

  Sources   Download

MIT

The Requires

 

The Development Requires

23/12 2016

dev-master

9999999-dev

PHP 5.3-compatible fork of guzzle/command

  Sources   Download

MIT

The Requires

 

The Development Requires

23/12 2016

v1.0.0

1.0.0.0

PHP 5.3-compatible fork of guzzle/command

  Sources   Download

MIT

The Requires

 

The Development Requires

24/11 2016

dev-guzzle6

dev-guzzle6

Provides the foundation for building command-based web service clients

  Sources   Download

MIT

The Requires

 

The Development Requires

17/02 2015

0.8.x-dev

0.8.9999999.9999999-dev

Provides the foundation for building command based web service clients

  Sources   Download

MIT

The Requires

 

The Development Requires