'PHP - Accessing Google Cloud Storage

I am trying to access a file from google cloud storage with PHP

A colleague who manages GCS gave me a json key file gcs_key.json.

I tried the following:

require '../vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;

$storage = new StorageClient([
    'keyFilePath' => '../web/gcs_key.json'
]);

But am getting an error saying:

Class 'Google\Cloud\Storage\StorageClient' not found

I have installed the necessary packages with composer as shown here:

composer require google/cloud

Key require is a duplicate in ./composer.json at line 9
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^0.176.0 for google/cloud
./composer.json has been updated
Key require is a duplicate in ./composer.json at line 9
Running composer update google/cloud
Loading composer repositories with package information
Package "google/cloud" listed for update is not locked.
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files

composer require google/cloud-storage

Key require is a duplicate in ./composer.json at line 9
Using version ^1.26 for google/cloud-storage
./composer.json has been updated
Key require is a duplicate in ./composer.json at line 9
Running composer update google/cloud-storage
Loading composer repositories with package information
Package "google/cloud-storage" listed for update is not locked.
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files

Am I missing something?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source