kandi background
Explore Kits

google-cloud-php | Google Cloud Client Library for PHP | GCP library

 by   googleapis PHP Version: v0.177.0 License: Apache-2.0

 by   googleapis PHP Version: v0.177.0 License: Apache-2.0

Download this library from

kandi X-RAY | google-cloud-php Summary

google-cloud-php is a PHP library typically used in Cloud, GCP applications. google-cloud-php has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
Idiomatic PHP client for Google Cloud Platform services.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • google-cloud-php has a medium active ecosystem.
  • It has 899 star(s) with 381 fork(s). There are 117 watchers for this library.
  • There were 1 major release(s) in the last 6 months.
  • There are 117 open issues and 1266 have been closed. On average issues are closed in 145 days. There are 59 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of google-cloud-php is v0.177.0
google-cloud-php Support
Best in #GCP
Average in #GCP
google-cloud-php Support
Best in #GCP
Average in #GCP

quality kandi Quality

  • google-cloud-php has 0 bugs and 0 code smells.
google-cloud-php Quality
Best in #GCP
Average in #GCP
google-cloud-php Quality
Best in #GCP
Average in #GCP

securitySecurity

  • google-cloud-php has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • google-cloud-php code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
google-cloud-php Security
Best in #GCP
Average in #GCP
google-cloud-php Security
Best in #GCP
Average in #GCP

license License

  • google-cloud-php is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
google-cloud-php License
Best in #GCP
Average in #GCP
google-cloud-php License
Best in #GCP
Average in #GCP

buildReuse

  • google-cloud-php releases are available to install and integrate.
  • Installation instructions, examples and code snippets are available.
  • It has 736548 lines of code, 86405 functions and 11775 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
google-cloud-php Reuse
Best in #GCP
Average in #GCP
google-cloud-php Reuse
Best in #GCP
Average in #GCP
Top functions reviewed by kandi - BETA

kandi has reviewed google-cloud-php and discovered the below as its top functions. This is intended to give you an instant insight into google-cloud-php implemented functionality, and help decide if they suit your requirements.

  • Convert a value to an object .
  • Sign a v4 URL .
  • Format a struct parameter .
  • Restores session pool .
  • Create composer .
  • Process a single component .
  • Filter fields recursively .
  • Builds the content of a description .
  • Add a filter to the query .
  • Performs a search .

google-cloud-php Key Features

Google Cloud Client Library for PHP

Quick Start

copy iconCopydownload iconDownload
$ composer require google/cloud-bigquery
$ composer require google/cloud-datastore

Authentication

copy iconCopydownload iconDownload
require 'vendor/autoload.php';

use Google\Cloud\Core\ServiceBuilder;

// Authenticate using a keyfile path
$cloud = new ServiceBuilder([
    'keyFilePath' => 'path/to/keyfile.json'
]);

// Authenticate using keyfile data
$cloud = new ServiceBuilder([
    'keyFile' => json_decode(file_get_contents('/path/to/keyfile.json'), true)
]);

gRPC and Protobuf

copy iconCopydownload iconDownload
$ pecl install grpc
$ pecl install protobuf

Caching Access Tokens

copy iconCopydownload iconDownload
require 'vendor/autoload.php';

use Google\Cloud\Storage\StorageClient;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

// Please take the proper precautions when storing your access tokens in a cache no matter the implementation.
$cache = new ArrayAdapter();

$storage = new StorageClient([
    'authCache' => $cache
]);

(Could not construct ApplicationDefaultCredentials) for PHP dialogflow

copy iconCopydownload iconDownload
putenv("GOOGLE_APPLICATION_CREDENTIALS=$path");

Google Storage - dynamically change ACL on single object (PHP)

copy iconCopydownload iconDownload
  $client = new Google_Client();
  $client->setApplicationName('GoogleBuck/0.1');
  $client->useApplicationDefaultCredentials(); // app engine env
  $client->addScope('https://www.googleapis.com/auth/devstorage.full_control'); 
  $storage = new Google_Service_Storage($client);
  $acl = new Google_Service_Storage_ObjectAccessControl($client);
  $acl->setEntity('allUsers');
  $acl->setRole('READER');
  $acl->setBucket($bucketName);
  $acl->setObject($objectName);
$response = $storage->objectAccessControls->insert($bucketName, $objectName, $acl);
$response = $storage->objectAccessControls->delete($bucketName, $objectName, 'allUsers');
 
-----------------------
  $client = new Google_Client();
  $client->setApplicationName('GoogleBuck/0.1');
  $client->useApplicationDefaultCredentials(); // app engine env
  $client->addScope('https://www.googleapis.com/auth/devstorage.full_control'); 
  $storage = new Google_Service_Storage($client);
  $acl = new Google_Service_Storage_ObjectAccessControl($client);
  $acl->setEntity('allUsers');
  $acl->setRole('READER');
  $acl->setBucket($bucketName);
  $acl->setObject($objectName);
$response = $storage->objectAccessControls->insert($bucketName, $objectName, $acl);
$response = $storage->objectAccessControls->delete($bucketName, $objectName, 'allUsers');
 
-----------------------
  $client = new Google_Client();
  $client->setApplicationName('GoogleBuck/0.1');
  $client->useApplicationDefaultCredentials(); // app engine env
  $client->addScope('https://www.googleapis.com/auth/devstorage.full_control'); 
  $storage = new Google_Service_Storage($client);
  $acl = new Google_Service_Storage_ObjectAccessControl($client);
  $acl->setEntity('allUsers');
  $acl->setRole('READER');
  $acl->setBucket($bucketName);
  $acl->setObject($objectName);
$response = $storage->objectAccessControls->insert($bucketName, $objectName, $acl);
$response = $storage->objectAccessControls->delete($bucketName, $objectName, 'allUsers');
 

How can I change the grpc.max_receive_message_length configuration in Google Cloud Text to speech on NodeJS?

copy iconCopydownload iconDownload
const client = new GoogleTextToSpeech.TextToSpeechClient({'grpc.max_receive_message_length': 1});

GCP setMetadata startup script to instance on Creation

copy iconCopydownload iconDownload
$instance = (new Instance())
    ->setName($instanceName)
    ->setDisks([$disk])
    ->setMachineType($machineTypeFullName)
    ->setNetworkInterfaces([$network])
    ->setMetadata([$metaData]);
$instance = (new Instance())
    ->setName($instanceName)
    ->setDisks([$disk])
    ->setMachineType($machineTypeFullName)
    ->setNetworkInterfaces([$network])
    ->setMetadata($metaData);
namespace Google\Cloud\Samples\Compute;
require_once 'vendor/autoload.php';


use Google\Cloud\Compute\V1\InstancesClient;
use Google\Cloud\Compute\V1\AttachedDisk;
use Google\Cloud\Compute\V1\AttachedDiskInitializeParams;
use Google\Cloud\Compute\V1\Instance;
use Google\Cloud\Compute\V1\NetworkInterface;
use Google\Cloud\Compute\V1\Operation;
use Google\Cloud\Compute\V1\ZoneOperationsClient;
use Google\Cloud\Compute\V1\AccessConfig;
use Google\Cloud\Compute\V1\Items;
use Google\Cloud\Compute\V1\Metadata;

function create_instance() {
    $projectId = 'impactful-name-324714';
    $zone = 'us-central1-c';
    $instanceName = 'test1-micro';
    $machineType = 'e2-micro';
    $sourceImage = 'projects/centos-cloud/global/images/family/centos-7';
    $networkName = 'global/networks/default';
    $networkTier = 'PREMIUM';
    // Set the machine type using the specified zone.
    $machineTypeFullName = sprintf('zones/%s/machineTypes/%s', $zone, $machineType);

    // Describe the source image of the boot disk to attach to the instance.
    $diskInitializeParams = (new AttachedDiskInitializeParams())
        ->setSourceImage($sourceImage);
    $disk = (new AttachedDisk())
        ->setBoot(true)
        ->setInitializeParams($diskInitializeParams);

    $metaItems = (new Items())
        ->setKey('startup-script')
        ->setValue('#_some_cmnd_I_want_to_exec_#');
    $metaData = (new Metadata())
        ->setItems([$metaItems]);

    // Use the network interface provided in the $networkName argument.
    $accessConfig = (new AccessConfig())
        ->setName('PREMIUM');
    
    $network = (new NetworkInterface())
        ->setAccessConfigs([$accessConfig]);
    
    // Create the Instance object.
    $instance = (new Instance())
        ->setName($instanceName)
        ->setDisks([$disk])
        ->setMachineType($machineTypeFullName)
        ->setNetworkInterfaces([$network])
        ->setMetadata($metaData);
        
    // Insert the new Compute Engine instance using InstancesClient.
    $instancesClient = new InstancesClient();
    $operation = $instancesClient->insert($instance, $projectId, $zone);

    // Wait for the create operation to complete.
    if ($operation->getStatus() === Operation\Status::RUNNING) {
        $operationClient = new ZoneOperationsClient();
        $operationClient->wait($operation->getName(), $projectId, $zone);
    }

    printf('Created instance %s' . PHP_EOL, $instanceName);
-----------------------
$instance = (new Instance())
    ->setName($instanceName)
    ->setDisks([$disk])
    ->setMachineType($machineTypeFullName)
    ->setNetworkInterfaces([$network])
    ->setMetadata([$metaData]);
$instance = (new Instance())
    ->setName($instanceName)
    ->setDisks([$disk])
    ->setMachineType($machineTypeFullName)
    ->setNetworkInterfaces([$network])
    ->setMetadata($metaData);
namespace Google\Cloud\Samples\Compute;
require_once 'vendor/autoload.php';


use Google\Cloud\Compute\V1\InstancesClient;
use Google\Cloud\Compute\V1\AttachedDisk;
use Google\Cloud\Compute\V1\AttachedDiskInitializeParams;
use Google\Cloud\Compute\V1\Instance;
use Google\Cloud\Compute\V1\NetworkInterface;
use Google\Cloud\Compute\V1\Operation;
use Google\Cloud\Compute\V1\ZoneOperationsClient;
use Google\Cloud\Compute\V1\AccessConfig;
use Google\Cloud\Compute\V1\Items;
use Google\Cloud\Compute\V1\Metadata;

function create_instance() {
    $projectId = 'impactful-name-324714';
    $zone = 'us-central1-c';
    $instanceName = 'test1-micro';
    $machineType = 'e2-micro';
    $sourceImage = 'projects/centos-cloud/global/images/family/centos-7';
    $networkName = 'global/networks/default';
    $networkTier = 'PREMIUM';
    // Set the machine type using the specified zone.
    $machineTypeFullName = sprintf('zones/%s/machineTypes/%s', $zone, $machineType);

    // Describe the source image of the boot disk to attach to the instance.
    $diskInitializeParams = (new AttachedDiskInitializeParams())
        ->setSourceImage($sourceImage);
    $disk = (new AttachedDisk())
        ->setBoot(true)
        ->setInitializeParams($diskInitializeParams);

    $metaItems = (new Items())
        ->setKey('startup-script')
        ->setValue('#_some_cmnd_I_want_to_exec_#');
    $metaData = (new Metadata())
        ->setItems([$metaItems]);

    // Use the network interface provided in the $networkName argument.
    $accessConfig = (new AccessConfig())
        ->setName('PREMIUM');
    
    $network = (new NetworkInterface())
        ->setAccessConfigs([$accessConfig]);
    
    // Create the Instance object.
    $instance = (new Instance())
        ->setName($instanceName)
        ->setDisks([$disk])
        ->setMachineType($machineTypeFullName)
        ->setNetworkInterfaces([$network])
        ->setMetadata($metaData);
        
    // Insert the new Compute Engine instance using InstancesClient.
    $instancesClient = new InstancesClient();
    $operation = $instancesClient->insert($instance, $projectId, $zone);

    // Wait for the create operation to complete.
    if ($operation->getStatus() === Operation\Status::RUNNING) {
        $operationClient = new ZoneOperationsClient();
        $operationClient->wait($operation->getName(), $projectId, $zone);
    }

    printf('Created instance %s' . PHP_EOL, $instanceName);
-----------------------
$instance = (new Instance())
    ->setName($instanceName)
    ->setDisks([$disk])
    ->setMachineType($machineTypeFullName)
    ->setNetworkInterfaces([$network])
    ->setMetadata([$metaData]);
$instance = (new Instance())
    ->setName($instanceName)
    ->setDisks([$disk])
    ->setMachineType($machineTypeFullName)
    ->setNetworkInterfaces([$network])
    ->setMetadata($metaData);
namespace Google\Cloud\Samples\Compute;
require_once 'vendor/autoload.php';


use Google\Cloud\Compute\V1\InstancesClient;
use Google\Cloud\Compute\V1\AttachedDisk;
use Google\Cloud\Compute\V1\AttachedDiskInitializeParams;
use Google\Cloud\Compute\V1\Instance;
use Google\Cloud\Compute\V1\NetworkInterface;
use Google\Cloud\Compute\V1\Operation;
use Google\Cloud\Compute\V1\ZoneOperationsClient;
use Google\Cloud\Compute\V1\AccessConfig;
use Google\Cloud\Compute\V1\Items;
use Google\Cloud\Compute\V1\Metadata;

function create_instance() {
    $projectId = 'impactful-name-324714';
    $zone = 'us-central1-c';
    $instanceName = 'test1-micro';
    $machineType = 'e2-micro';
    $sourceImage = 'projects/centos-cloud/global/images/family/centos-7';
    $networkName = 'global/networks/default';
    $networkTier = 'PREMIUM';
    // Set the machine type using the specified zone.
    $machineTypeFullName = sprintf('zones/%s/machineTypes/%s', $zone, $machineType);

    // Describe the source image of the boot disk to attach to the instance.
    $diskInitializeParams = (new AttachedDiskInitializeParams())
        ->setSourceImage($sourceImage);
    $disk = (new AttachedDisk())
        ->setBoot(true)
        ->setInitializeParams($diskInitializeParams);

    $metaItems = (new Items())
        ->setKey('startup-script')
        ->setValue('#_some_cmnd_I_want_to_exec_#');
    $metaData = (new Metadata())
        ->setItems([$metaItems]);

    // Use the network interface provided in the $networkName argument.
    $accessConfig = (new AccessConfig())
        ->setName('PREMIUM');
    
    $network = (new NetworkInterface())
        ->setAccessConfigs([$accessConfig]);
    
    // Create the Instance object.
    $instance = (new Instance())
        ->setName($instanceName)
        ->setDisks([$disk])
        ->setMachineType($machineTypeFullName)
        ->setNetworkInterfaces([$network])
        ->setMetadata($metaData);
        
    // Insert the new Compute Engine instance using InstancesClient.
    $instancesClient = new InstancesClient();
    $operation = $instancesClient->insert($instance, $projectId, $zone);

    // Wait for the create operation to complete.
    if ($operation->getStatus() === Operation\Status::RUNNING) {
        $operationClient = new ZoneOperationsClient();
        $operationClient->wait($operation->getName(), $projectId, $zone);
    }

    printf('Created instance %s' . PHP_EOL, $instanceName);

DialogFlow Detect Intent stuck

copy iconCopydownload iconDownload
FROM php:7-fpm
RUN apt-get update -q -q && apt-get install -y zlib1g-dev \
    && pecl install grpc \
    && docker-php-ext-enable grpc

BigQuery Results directly in GCS - PHP API

copy iconCopydownload iconDownload
<?php

use Google\Cloud\BigQuery\BigQueryClient;

$bigquery = new BigQueryClient();

$datasetId = "my-dataset";
$tableId = "my-new-table";
$gsUri = "gs://my-bucket/my-object";

$queryString = "SELECT * FROM `bigquery-public-data.austin_311.311_request` LIMIT 1000";

$newTable = $bigquery->dataset($datasetId)
    ->table($tableId);

$q = $bigquery->query($queryString);
$q->destinationTable($newTable);

$bigquery->runQuery($q)
    ->waitUntilComplete();

$extract = $newTable->extract($gsUri);

$newTable->runJob($extract);

$newTable->delete();
-----------------------
EXPORT DATA OPTIONS(
  uri='gs://bucket/folder/*.csv',
  format='CSV',
  overwrite=true,
  header=true,
  field_delimiter=';') AS
SELECT field1, field2 
FROM table1 
ORDER BY field1 
LIMIT 10

Google Storage signedUploadUrl, fetching upload url returns: Bad content type. Please use multipart

copy iconCopydownload iconDownload
curl -X PUT -H 'Content-Type: application/octet-stream' --upload-file /path/to/file.jpg 
https://storage.googleapis.com/my-project-id.appspot.com/uploads/uploadfilename.jpg?GoogleAccessId=myserviceaccount
@mydomain.com&Expires=1591657512&Signature=veryverylongsignatureasdfasdfasdfasdfadfa
sdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfa
sdfasdfasdfasdfasdfasdfasdfasdfasdf
curl -X PUT -H 'Content-Type: application/octet-stream' --upload-file /path/to/file.jpg 
"https://storage.googleapis.com/my-project-id.appspot.com/uploads/uploadfilename.jpg?GoogleAccessId=myserviceaccount
@mydomain.com&Expires=1591657512&Signature=veryverylongsignatureasdfasdfasdfasdfadfa
sdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfa
sdfasdfasdfasdfasdfasdfasdfasdfasdf"
-----------------------
curl -X PUT -H 'Content-Type: application/octet-stream' --upload-file /path/to/file.jpg 
https://storage.googleapis.com/my-project-id.appspot.com/uploads/uploadfilename.jpg?GoogleAccessId=myserviceaccount
@mydomain.com&Expires=1591657512&Signature=veryverylongsignatureasdfasdfasdfasdfadfa
sdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfa
sdfasdfasdfasdfasdfasdfasdfasdfasdf
curl -X PUT -H 'Content-Type: application/octet-stream' --upload-file /path/to/file.jpg 
"https://storage.googleapis.com/my-project-id.appspot.com/uploads/uploadfilename.jpg?GoogleAccessId=myserviceaccount
@mydomain.com&Expires=1591657512&Signature=veryverylongsignatureasdfasdfasdfasdfadfa
sdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfa
sdfasdfasdfasdfasdfasdfasdfasdfasdf"

Community Discussions

Trending Discussions on google-cloud-php
  • (Could not construct ApplicationDefaultCredentials) for PHP dialogflow
  • Lack of null inequality support in Firestore's PHP SDK
  • Google Storage - dynamically change ACL on single object (PHP)
  • How can I change the grpc.max_receive_message_length configuration in Google Cloud Text to speech on NodeJS?
  • GCP setMetadata startup script to instance on Creation
  • DialogFlow Detect Intent stuck
  • BigQuery Results directly in GCS - PHP API
  • How do you use the &quot;Bytes&quot; data type in Google Firestore in PHP?
  • Google Storage signedUploadUrl, fetching upload url returns: Bad content type. Please use multipart
Trending Discussions on google-cloud-php

QUESTION

(Could not construct ApplicationDefaultCredentials) for PHP dialogflow

Asked 2022-Mar-10 at 10:38
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Dialogflow\V2\EntityTypesClient;

$storage = new StorageClient([
            'keyFile' => json_decode(file_get_contents(storage_path('app/public/tunepath-bot-tkpf-811257321355.json')), true)
        ]);

        $entityTypesClient = new EntityTypesClient();
        $projectId = '[project_id]';
        $entityTypeId = '[ENTITY_TYPE_ID]';
        $formattedEntityTypeName = $entityTypesClient->entityTypeName($projectId, $entityTypeId);

        $entityType = $entityTypesClient->getEntityType($formattedEntityTypeName);
        foreach ($entityType->getEntities() as $entity) {
            print(PHP_EOL);
            printf('Entity value: %s' . PHP_EOL, $entity->getValue());
            print('Synonyms: ');
            foreach ($entity->getSynonyms() as $synonym) {
                print($synonym . "\t");
            }
            print(PHP_EOL);
        }

I have done according to documentation https://github.com/googleapis/google-cloud-php-dialogflow. I got this error - Could not construct ApplicationDefaultCredentials

ANSWER

Answered 2022-Mar-10 at 10:38
putenv("GOOGLE_APPLICATION_CREDENTIALS=$path");

$path -> path to google service acccount json file. put this code above.

Source https://stackoverflow.com/questions/70966900

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install google-cloud-php

We recommend installing individual component packages when possible. A list of available packages can be found on Packagist. We also provide the google/cloud package, which includes all Google Cloud clients.

Support

Contributions to this library are always welcome and highly encouraged. See CONTRIBUTING for more information on how to get started.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.