hprotravel / symfony-gcp-rest-bundle
Client bundle for Google Cloud Platform REST API endpoints
Requires
- hprotravel/php-gcp-rest-client: ^0.4.0
- symfony/config: ~2.7|~3.0|~4.0|~5.0
- symfony/dependency-injection: ~2.7|~3.0|~4.0|~5.0
- symfony/event-dispatcher: ~2.7|~3.0|~4.0|~5.0
- symfony/yaml: ~2.7|~3.0|~4.0|~5.0
Requires (Dev)
- phpunit/phpunit: ^5.0
README
Symfony Bundle built-on Guzzle for Google Cloud Platform REST APIs
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
Installation
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
$ composer require hprotravel/symfony-gcp-rest-bundle
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require hprotravel/symfony-gcp-rest-bundle
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
// config/bundles.php
return [
// ...
GcpRestGuzzleAdapterBundle\GcpRestGuzzleAdapterBundle::class => ['all' => true],
];
Step 3: Configuration
gcp_rest_guzzle_adapter:
clients:
pubsub:
email: 'test@test.com'
private_key: "-----BEGIN PRIVATE KEY-----SDADAavaf...-----END PRIVATE KEY-----"
scope: 'https://www.googleapis.com/auth/pubsub'
project_base_url: 'https://pubsub.googleapis.com/v1/projects/test-project123/'
Note: Double quote for private_key. Single quote occur openssl_sign error
Accessing Service by container
$pubSubClient = $container->get('gcp_rest_guzzle_adapter.client.pubsub_client');
$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"
]
}
"