hprotravel / php-gcp-rest-client
Simple Guzzle adapter to Google Cloud Platform REST endpoints
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Package info
bitbucket.org/hprotravel/php-gcp-rest-client
pkg:composer/hprotravel/php-gcp-rest-client
v0.4.1
2022-12-14 09:29 UTC
Requires
- php: ^7.2.5 || ^8.0
- ext-apcu: *
- ext-json: *
- firebase/php-jwt: 4.0
- guzzlehttp/guzzle: ^7.4
Requires (Dev)
- phpunit/phpunit: ^9.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Simple Guzzle adapter to Google Cloud Platform REST APIs
Use Case
Accessing to Google Cloud Platform Rest APIs using Service Account Credentials (Google's recommended way)
For more information about authentication: https://cloud.google.com/speech/docs/common/auth
Usage
use \GcpRestGuzzleAdapter\Client\ClientFactory;
// Service Account Email
$email = 'pubsub@test-project123.iam.gserviceaccount.com';
// Private Key
$key = '-----BEGIN PRIVATE KEY-----SDADAavaf...-----END PRIVATE KEY-----';
// Scope of Google Cloud Service
$scope = 'https://www.googleapis.com/auth/pubsub';
// Full base url of project
$projectBaseUrl = 'https://pubsub.googleapis.com/v1/projects/test-project123/';
$pubSubClient = ClientFactory::createClient($email, $key, $scope, $projectBaseUrl);
$result = $pubSubClient->get(
sprintf('topics/%s/subscriptions', 'test-topic')
);
var_dump((string)$result->getBody()->getContents());
Result
string(113) "{
"subscriptions": [
"projects/test-project123/subscriptions/test_topicSubscriber"
]
}
"
Requirements
- php: ^7.2.5 || ^8.0
- guzzlehttp/guzzle: ^7.4
- firebase/php-jwt: 4.0
- apc or apcu for token caching (custom handler also injectable)