Download the PHP package guzzlehttp/command without Composer
On this page you can find all versions of the php package guzzlehttp/command. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download guzzlehttp/command
More information about guzzlehttp/command
Files in guzzlehttp/command
Package command
Short Description Provides the foundation for building command-based web service clients
License MIT
Informations about the package command
Guzzle Commands
This library uses Guzzle 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.
Commands
Key-value pair objects representing an operation of a web service. Commands have a name and a set of parameters.
Results
Key-value pair objects representing the processed result of executing an operation of a web service.
Installing
This project can be installed using Composer:
Service Clients
Service Clients are web service clients that implement the
GuzzleHttp\Command\ServiceClientInterface
and use an underlying Guzzle HTTP
client (GuzzleHttp\ClientInterface
) to communicate with the service. Service
clients create and execute commands (GuzzleHttp\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 GuzzleHttp\Command\ServiceClient
class.
Instantiating a Service Client
The provided service client implementation (GuzzleHttp\Command\ServiceClient
)
can be instantiated by providing the following arguments:
- A fully-configured Guzzle HTTP client that will be used to perform the
underlying HTTP requests. That is, an instance of an object implementing
GuzzleHttp\ClientInterface
such asnew GuzzleHttp\Client()
. - A callable that transforms a Command into a Request. The function should
accept a
GuzzleHttp\Command\CommandInterface
object and return aPsr\Http\Message\RequestInterface
object. - A callable that transforms a Response into a Result. The function should
accept a
Psr\Http\Message\ResponseInterface
object and optionally aPsr\Http\Message\RequestInterface
object, and return aGuzzleHttp\Command\ResultInterface
object. - Optionally, a Guzzle HandlerStack (
GuzzleHttp\HandlerStack
), which can be used to add command-level middleware to the service client.
Below is an example configured to send and receive JSON payloads:
Executing Commands
Service clients create command objects using the getCommand()
method.
After creating a command, you may execute the command using the execute()
method of the client.
The result of executing a command will be an instance of an object implementing
GuzzleHttp\Command\ResultInterface
. Result objects are ArrayAccess
-ible and
contain the data parsed from HTTP response.
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.
Asynchronous Commands
@TODO Add documentation
-Async
suffix for client methods- Promises
@TODO Add documentation
wait()
-ing on promises.
Concurrent Requests
@TODO Add documentation
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.
Security
If you discover a security vulnerability within this package, please send an email to [email protected]. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see Security Policy for more information.
License
Guzzle is made available under the MIT License (MIT). Please see License File for more information.
For Enterprise
Available as part of the Tidelift Subscription
The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
All versions of command with dependencies
guzzlehttp/guzzle Version ^7.8
guzzlehttp/promises Version ^1.5.3 || ^2.0.1
guzzlehttp/psr7 Version ^1.9.1 || ^2.5.1