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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

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:

  1. 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 as new GuzzleHttp\Client().
  2. A callable that transforms a Command into a Request. The function should accept a GuzzleHttp\Command\CommandInterface object and return a Psr\Http\Message\RequestInterface object.
  3. A callable that transforms a Response into a Result. The function should accept a Psr\Http\Message\ResponseInterface object and optionally a Psr\Http\Message\RequestInterface object, and return a GuzzleHttp\Command\ResultInterface object.
  4. 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.

Per-command HTTP options

GuzzleHttp\Command\ServiceClient reserves the @http command parameter for per-command Guzzle request options. When a command is executed, the service client reads $command['@http'], removes it from the command, transforms the remaining command data into a PSR-7 request, and passes the @http array to the underlying Guzzle HTTP client.

This is intended for trusted application code that needs to adjust transport behavior for a single command, such as setting a shorter timeout. Treat @http as a reserved control key, not as an operation parameter. Do not pass untrusted input directly into command arguments without filtering it first. If external input can include @http, that input may be able to influence the underlying HTTP request or transfer depending on the configured Guzzle client and handler. The @http value must be an array of Guzzle request options. Be especially careful with options that affect the target URI, proxy, TLS verification, headers, body, response sink, redirects, or timeouts.

Build command arguments from an allowlist of expected operation parameters, or explicitly reject reserved keys such as @http before creating commands:

When setting per-command HTTP options intentionally, only expose and validate the specific options your application needs:

Because @http is removed during execution, create a new command if you need to execute the same operation again with the same per-command HTTP options.

Asynchronous Commands

Commands can be executed asynchronously using executeAsync(). This method returns a GuzzleHttp\Promise\PromiseInterface that resolves to a GuzzleHttp\Command\ResultInterface.

Synchronous execution is equivalent to waiting on the asynchronous operation:

Magic methods may also be used asynchronously by appending Async to the operation name. For example, fooAsync() creates a foo command and executes it asynchronously:

If execution fails, the promise is rejected with a GuzzleHttp\Command\Exception\CommandException. When HTTP errors are enabled, 4xx and 5xx responses are represented by CommandClientException and CommandServerException, respectively, when the underlying Guzzle exception contains a response.

Concurrent Requests

Use executeAll() or executeAllAsync() to execute multiple commands with a fixed concurrency limit. Both methods accept an array or iterator that yields CommandInterface objects.

executeAll() waits for the pool to finish and returns an array keyed like the input commands. Successful entries contain results. Failed entries contain the rejection reason, typically a CommandException.

executeAllAsync() returns a promise for the command pool instead of waiting for it immediately. The same options are supported:

The supported options are:

Choose a concurrency value that is appropriate for the remote service and your application. Very large command lists should generally be streamed with an iterator rather than built eagerly as a large array.

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.

Command middleware is added to the service client's handler stack and wraps commands before they are transformed into HTTP requests. HTTP middleware should be configured on the underlying Guzzle HTTP client instead.

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

PHP Build Version
Package Version
Requires php Version ^7.2.5 || ^8.0
guzzlehttp/guzzle Version ^7.10
guzzlehttp/promises Version ^2.3
guzzlehttp/psr7 Version ^2.8
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package guzzlehttp/command contains the following files

Loading the files please wait ...