hprotravel/symfony-gcp-rest-bundle

Client bundle for Google Cloud Platform REST API endpoints

Installs: 1 026

Dependents: 0

Suggesters: 0

Security: 0

Type:symfony-bundle

v0.4.0 2022-12-06 12:16 UTC

This package is auto-updated.

Last update: 2024-05-05 16:38:37 UTC


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"
  ]
}
"