Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Gax Laravel Package

google/gax

Google API Core for PHP (gax-php) provides modules that help build gRPC-based API clients following Google API conventions, powering features like page streaming and retry in generated client libraries. Requires PHP 8.1+.

View on GitHub
Deep Wiki
Context7

Google API Extensions for PHP

Frequently asked questions about Gax
What is google/gax used for in PHP?
Google API Core for PHP provides shared runtime components for generated Google Cloud API clients. It handles gRPC-based calls, retries, timeouts, page streaming, and Google API conventions. Most application code uses it indirectly through clients such as FirestoreClient rather than calling Google\ApiCore classes directly.
Do I need to install google/gax directly in a Laravel app?
Usually no, because it is pulled in transitively by generated Google Cloud PHP clients. Install it directly only if you are building or customizing a generated client or need its middleware and transport classes. For typical Firestore, Pub/Sub, or BigQuery usage, require the service-specific client package instead.
Is google/gax compatible with Laravel 9 and PHP 8.1?
Yes, gax-php requires PHP 8.1 or higher, so Laravel 9 and newer on PHP 8.1+ are compatible. Older Laravel versions running on PHP 8.0 or below would need an upgrade. Check your other Google Cloud dependencies for matching PHP and protobuf constraints.
How do I install google/gax with Composer?
Run composer require google/gax in your Laravel project. You will also need google/protobuf and, for gRPC transport, the grpc/grpc PHP extension installed at the system level. The package itself is installed via Composer, but gRPC is not a normal Composer-only dependency.
Does google/gax require the gRPC PHP extension?
gRPC-based Google Cloud clients rely on the grpc/grpc PHP extension, which must be installed system-wide, often via pecl or your OS package manager. Without it, gRPC transport will not work, though some clients can use REST fallbacks depending on their configuration. Verify the extension is enabled in the same PHP runtime that serves Laravel.
What is the difference between gRPC and REST for Google Cloud in Laravel?
gRPC uses Protobuf and HTTP/2 and is well suited to streaming, low-latency, and high-throughput Google Cloud APIs. REST is simpler to operate but may not expose every streaming or advanced feature. google/gax is designed around gRPC conventions, so it adds the most value when your Laravel app uses gRPC-native clients.
How do retries and timeouts work with google/gax?
Generated clients pass retry and timeout settings into gax-php, which applies Google API retry policies around calls. You typically configure these through client options rather than writing retry loops yourself. This helps handle transient failures, but you should still test behavior for your specific API and workload.
Can google/gax handle page streaming for Google Cloud APIs?
Yes, gax-php provides page streaming support used by generated clients to iterate paginated API results. Instead of manually fetching page tokens, you can iterate over results through the generated client methods. This is one of the conveniences gax-php provides so application code stays idiomatic.
How can I add logging or middleware to Google API calls in Laravel?
gax-php supports middleware through mechanisms such as GapicClientTrait::prependMiddleware and TransportCallMiddleware. You can use this to intercept requests and responses for logging, metrics, or custom headers. Keep middleware lightweight and test it against real gRPC calls, since debugging transport-level issues can be complex.
How do I test google/gax error handling in Laravel?
Focus on the generated client behavior and catch Google\ApiCore\ApiException where appropriate. You can assert structured error details with getErrorDetails and simulate failures in integration tests. Unit tests can mock client methods, but streaming and retry behavior usually need gRPC-aware integration tests.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log