Download the PHP package bigcommerce/grphp without Composer

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

grphp - gRPC PHP Framework

Build Status

grphp is a PHP framework that wraps the gRPC PHP library to provide a more streamlined integration into PHP applications.

It provides an abstracted client for gRPC services, along with other tools to help get gRPC services in PHP up fast and efficiently at scale. Some of its features include:

grphp currently has active support for gRPC 1.9.0, and requires PHP 7.4+ to run.

Installation

You'll need to make sure you fit the requirements for the grpc/grpc PHP library, which does involve installing the gRPC PHP extension (unless you are using the H2Proxy strategy).

Client

Strategy

grphp comes with the ability to utilize injectable strategies for how it communicates outward. Currently, there are two strategies that come packaged with grphp:

H2Proxy Strategy

The H2Proxy strategy pairs with a nghttpx service and sends HTTP/1.1 requests that are upgraded to HTTP/2 and gRPC. It does this by sending the binary encoded protobuf across the wire with the Upgrade: h2c and Connection: Upgrade headers, which nghttpx uses to upgrade the connection into a proper gRPC request.

This is useful if you do not want to utilize the gRPC PHP C extension but still gain the benefit of the protobuf contracts. If you do not have the gRPC PHP C extension installed, grphp will automatically switch you to the H2Proxy strategy.

You can use and configure the proxy strategy like so, assuming we have a nghttpx service running at the address 0.0.0.0 on port 3000:

This sets the proxy client to also utilize a timeout of 15 seconds. This setup is configurable per-client, so you can adjust these settings - and the strategy - on a service-by-service basis.

Envoy Strategy

The Envoy strategy uses Envoy as an HTTP/1.1 bridge for gRPC egress traffic. It automatically serializes messages and buffers requests to handle the response trailers. More can be read about the Envoy bridge here.

This sets the proxy client to also utilize a timeout of 2 seconds. This setup is configurable per-client, so you can adjust these settings - and the strategy - on a service-by-service basis.

Authentication

Authentication is done via adapters, which are specified in the config. You can either pass in:

Basic Authentication

grphp supports basic auth for requests that is sent through the metadata of the request.

Custom Client Interceptors

grphp comes with a base Client Interceptor class that can be extended to provide your own custom interceptors. This is an example interceptor that adds a "X-Foo" header with a customizable value to all metadata:

You'll note that you have to make sure to execute the callback that is called.

Then you add it as normal:

Interceptors run in the order that they are added, wrapping each as they go.

Retry Interceptor

Retries can be enabled for given gRPC error status codes with the Retry interceptor.

The retry behaviour can be customized by passing in an array of options to the constructor. The following options are available:

Option Default Description
max_retries 3 The maximum number of retries to attempt.
retry_on_statuses [Grphp\Client\Error::CODE_UNAVAILABLE] An array of gRPC error status codes that should be retried on.
delay_milliseconds 200 The initial delay in milliseconds before a retry.
backoff_func function (int $attempt, int $delayMilliseconds) { /* exponential backoff with jitter */ } A callback defining the backoff behaviour.

Error Handling

gRPC prefers handling errors through status (BadStatus) codes; however, these do not return much information as to field specific errors, application codes, or debug information. grphp provides a way to read data from the response metadata, which is stored in the error-internal-bin key (configurable through the error_metadata_key configuration option).

Assuming we have a service that has a method that appends that data, you can access it like so:

By default the deserializer for the data is JSON; it's fairly simple to create your own, such as one that has the error header serialized as a binary protobuf. From there, you can set it simply:

The serializer can be passed as a string name of the class or the instance of the class. If you pass the string name, you can pass in an associative array of error_serializer_options to the config to provide options for your serializer.

Roadmap

License

Copyright (c) 2017-present, BigCommerce Pty. Ltd. All rights reserved

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


All versions of grphp with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
google/protobuf Version ^3.7
grpc/grpc Version ^1.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 bigcommerce/grphp contains the following files

Loading the files please wait ....