2017 © Pedro Peláez
 

library flysystem-google-storage

Flysystem adapter for Google Cloud Storage

image

superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

  • Wednesday, February 7, 2018
  • by matthewgoslett
  • Repository
  • 30 Watchers
  • 100 Stars
  • 451,343 Installations
  • PHP
  • 13 Dependents
  • 2 Suggesters
  • 35 Forks
  • 10 Open issues
  • 23 Versions
  • 22 % Grown

The README.md

flysystem-google-cloud-storage

A Google Cloud Storage adapter for flysystem - a PHP filesystem abstraction., (*1)

Author Build Status StyleCI Software License Packagist Version Total Downloads, (*2)

Installation

composer require superbalist/flysystem-google-storage

Integrations

Want to get started quickly? Check out some of these integrations:, (*3)

  • Laravel - https://github.com/Superbalist/laravel-google-cloud-storage

Usage

use Google\Cloud\Storage\StorageClient;
use League\Flysystem\Filesystem;
use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter;

/**
 * The credentials will be auto-loaded by the Google Cloud Client.
 *
 * 1. The client will first look at the GOOGLE_APPLICATION_CREDENTIALS env var.
 *    You can use ```putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');``` to set the location of your credentials file.
 *
 * 2. The client will look for the credentials file at the following paths:
 * - windows: %APPDATA%/gcloud/application_default_credentials.json
 * - others: $HOME/.config/gcloud/application_default_credentials.json
 *
 * If running in Google App Engine, the built-in service account associated with the application will be used.
 * If running in Google Compute Engine, the built-in service account associated with the virtual machine instance will be used.
 */

$storageClient = new StorageClient([
    'projectId' => 'your-project-id',
]);
$bucket = $storageClient->bucket('your-bucket-name');

$adapter = new GoogleStorageAdapter($storageClient, $bucket);

$filesystem = new Filesystem($adapter);

/**
 * The credentials are manually specified by passing in a keyFilePath.
 */

$storageClient = new StorageClient([
    'projectId' => 'your-project-id',
    'keyFilePath' => '/path/to/service-account.json',
]);
$bucket = $storageClient->bucket('your-bucket-name');

$adapter = new GoogleStorageAdapter($storageClient, $bucket);

$filesystem = new Filesystem($adapter);

// write a file
$filesystem->write('path/to/file.txt', 'contents');

// update a file
$filesystem->update('path/to/file.txt', 'new contents');

// read a file
$contents = $filesystem->read('path/to/file.txt');

// check if a file exists
$exists = $filesystem->has('path/to/file.txt');

// delete a file
$filesystem->delete('path/to/file.txt');

// rename a file
$filesystem->rename('filename.txt', 'newname.txt');

// copy a file
$filesystem->copy('filename.txt', 'duplicate.txt');

// delete a directory
$filesystem->deleteDir('path/to/directory');

// see http://flysystem.thephpleague.com/api/ for full list of available functionality

Google Storage specifics

When using a custom storage uri the bucket name will not prepended to the file path., (*4)

$storageClient = new StorageClient([
    'projectId' => 'your-project-id',
]);
$bucket = $storageClient->bucket('your-bucket-name');
$adapter = new GoogleStorageAdapter($storageClient, $bucket);

// uri defaults to "https://storage.googleapis.com"
$filesystem = new Filesystem($adapter);
$filesystem->getUrl('path/to/file.txt');
// "https://storage.googleapis.com/your-bucket-name/path/to/file.txt"

// set custom storage uri
$adapter->setStorageApiUri('http://example.com');
$filesystem = new Filesystem($adapter);
$filesystem->getUrl('path/to/file.txt');
// "http://example.com/path/to/file.txt"

// You can also prefix the file path if needed.
$adapter->setStorageApiUri('http://example.com');
$adapter->setPathPrefix('extra-folder/another-folder/');
$filesystem = new Filesystem($adapter);
$filesystem->getUrl('path/to/file.txt');
// "http://example.com/extra-folder/another-folder/path/to/file.txt"

The Versions

07/02 2018

dev-analysis-XZ4Yvn

dev-analysis-XZ4Yvn

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

07/02 2018

dev-master

9999999-dev

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

07/02 2018

7.0.0

7.0.0.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

08/01 2018

6.0.0

6.0.0.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

14/11 2017

dev-test-all-the-things

dev-test-all-the-things

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

21/10 2017

dev-fix-custom-uri-bucket-prepend

dev-fix-custom-uri-bucket-prepend

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

18/07 2017

5.0.3

5.0.3.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

04/07 2017

5.0.2

5.0.2.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

19/05 2017

5.0.1

5.0.1.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

03/04 2017

5.0.0

5.0.0.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

10/02 2017

4.0.2

4.0.2.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

03/01 2017

4.0.1

4.0.1.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

03/01 2017

4.0.0

4.0.0.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

03/01 2017

3.0.4

3.0.4.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

05/10 2016

3.0.3

3.0.3.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

27/09 2016

3.0.2

3.0.2.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

27/09 2016

3.0.1

3.0.1.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

26/09 2016

3.0.0

3.0.0.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

19/05 2016

2.0.0-RC1

2.0.0.0-RC1

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

19/05 2016

1.0.4

1.0.4.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

12/04 2016

1.0.3

1.0.3.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

29/03 2016

1.0.1

1.0.1.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd

16/10 2015

1.0.0

1.0.0.0

Flysystem adapter for Google Cloud Storage

  Sources   Download

MIT

The Requires

 

The Development Requires

by Superbalist.com a division of Takealot Online (Pty) Ltd