google/gax
Google API Core for PHP (gax-php) provides shared components used by generated Google Cloud API clients, including gRPC-based call handling, retries, timeouts, and page streaming. Designed for PHP 8.1+ and Google API conventions; most users won’t call it directly.
.proto files), which may require additional tooling (e.g., protoc) in the Laravel build pipeline.grpc/grpc) and Protobuf (google/protobuf), which may introduce additional setup complexity.TransportCallMiddleware), which can be integrated into Laravel’s middleware pipeline for cross-cutting concerns (e.g., logging, auth).protoc compiler for generating PHP clients from .proto files, adding build complexity.ApiException handling may conflict with Laravel’s exception strategies (e.g., App\Exceptions\Handler)..proto files be managed? Will they be version-controlled or generated dynamically?google/cloud-core)?Google\Cloud\PubSub\V1\PublisherClient) injected via the service container.protoc and protoc-gen-php for generating PHP clients..proto files for target APIs (or use Google’s generated ones).composer require google/gax google/protobuf grpc/grpc
config/app.php or via service providers.$this->app->bind(
Google\Cloud\PubSub\V1\PublisherClient::class,
fn() => new Google\Cloud\PubSub\V1\PublisherClient([
'credentials' => Storage::disk('local')->get('service-account.json'),
])
);
TransportCallMiddleware for cross-cutting concerns (e.g., logging, auth).$client->prependMiddleware(new class implements TransportCallMiddleware {
public function handle(callable $next, Request $request) {
// Add auth headers, logging, etc.
return $next($request);
}
});
spatie/fractal) for gRPC retries.ApiException details for debugging.grpc/grpc package (not google/gax’s bundled gRPC).CredentialsWrapper or custom middleware.Google\ApiCore\ApiClientInterface)..proto files must be version-controlled and regenerated on updates.ApiException handling may require updates to Laravel’s App\Exceptions\Handler.grpc.status) need to be routed to Laravel’s logging system (e.g., Monolog).grpc_cli).Grpc\ChannelCredentials).| Failure Type | Impact | Mitigation |
|---|---|---|
| gRPC Connection Drops | Timeouts, failed API calls | Retry middleware, circuit breakers |
| Protobuf Serialization | Corrupted requests/responses | Validate schemas, use protoc linting |
| Auth Token Expiry | 401 Unauthorized errors | Refresh tokens via CredentialsWrapper |
| Google Cloud Outages | API unavailability | Fallback to REST or local caching |
| Dependency Conflicts | Breaking changes in google/gax |
Pin versions in composer.json |
How can I help you explore Laravel packages today?