Download the PHP package spiral/grpc-client without Composer

On this page you can find all versions of the php package spiral/grpc-client. 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 grpc-client

gRPC Client

The package provides powerful and convenient functionality for making client gRPC requests through a simple and extensible interface.

Installation

PHP Latest Version on Packagist Total downloads

Note that the package requires gRPC extension to be installed.

Documentation

Public API

The package provides the following parts of the API:

Integration

Spiral

[!NOTE] The spiral/roadrunner-bridge package includes the spiral/grpc-client package by default since version 4.0.0 and provides its integration and configuration flow.

Add the \Spiral\Grpc\Client\Bridge\GrpcClientBootloader bootloader to the list of bootloaders in the application configuration (usually it is Kernel.php).

Other Frameworks

If you are using this package outside the Spiral framework, you need to figure out how to use the \Spiral\Grpc\Client\ServiceClientProvider provider to get ready-to-use gRPC clients.

Configuration DTOs

Now let's consider a configuration example:

GrpcClientConfig

This class represents the configuration of the gRPC client in general. It includes a list of service configurations and a general list of interceptors that will be applied to all services.

Interceptors can be declared as class names, Spiral\Core\Container\Autowire objects (if custom constructor arguments need to be passed), or objects. Note that some interceptors provide convenient methods for creating configurations.

ServiceConfig

This class represents the configuration of a specific service or a group of similar services but with different connection options.

The interfaces parameter is a list of gRPC service interfaces that were generated by the protoc utility and that are implemented by the service.

[!NOTE] Currently, we support only service interfaces that are generated using the protoc utility with the protoc-gen-php-grpc plugin.

The configuration example above doesn't include the interceptors parameter. It's the same as in the general configuration, but it's applied only to the specified service. This branch of interceptors is run via the ExecuteServiceInterceptors interceptor. So, it's important to include it if you want to use service-specific interceptors.

The connections parameter is a list of connection configurations. You can specify multiple connections to distribute the load between them or to provide fail-over. Multi-connection orchestration strategy can be configured by interceptors, for example, ConnectionsRotationInterceptor.

ConnectionConfig

This class represents the configuration of a single connection to the gRPC service. It includes credentials and the service address.

To create a secure connection, use the TlsConfig class.

Usage

After the integration and configuration are ready, you can get the client for the desired service interface from the container and call the service methods.

Interceptors

Important points when using interceptors in the long-running mode:

When writing your own interceptors, you will likely want to work with gRPC-specific fields (options, metadata, input message, etc.). Use the \Spiral\Grpc\Client\Interceptor\Helper class to get or set the values of these context fields.

Order of Interceptors

Interceptors are executed in the order in which they are declared in the configuration. The order of the interceptors is important.

For example, if we have the following configuration:

  1. SetTimeout(10 seconds)
  2. Retry(maxAttempts: 3, interval: 2 seconds)
  3. SetTimeout(3 seconds)

then we will have a 3-second timeout for each retry attempt.
We also have a 10-second timeout for all attempts in total, after which no new request attempts will be made. This happens because the RetryInterceptor takes into account previously configured timeouts.

Also, the placement of the ExecuteServiceInterceptors interceptor, which embeds the interceptors of the currently running service, will affect the final sequence of interceptors.


All versions of grpc-client with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
google/common-protos Version ^1.3 || ^2.0 || ^3.0 || ^4.0
google/protobuf Version ^3 || ^4
grpc/grpc Version ^1.57
psr/container Version ^2.0
spiral/core Version ^3.14
spiral/hmvc Version ^3.14
spiral/tokenizer Version ^3.13
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 spiral/grpc-client contains the following files

Loading the files please wait ....