A Google services wrapper library for creating Google Drive.

v0.1.1 2019-04-23 00:54 UTC

This package is auto-updated.

Last update: 2024-04-23 11:41:09 UTC


README

Build Status codecov License composer.lock

This package was created for a project I am working on and does not fully support Google services (or the way you may want it to). Feel free to add functionality by creating a pull request. See contributing.

Installation

You can install the package via composer:

$ composer require basecardhero/drive

Usage

You will need to configure the Google Client. See gsuitedevs/php-samples for examples configuring a Google Client for php.

Examples

Create a Drive instance

require_once '/project/path/vendor/autoload.php';

$client = new \Google_Client(); // Make sure to configure your Google client.
$driveService = new \Google_Service_Drive($client);
$drive = new \BaseCardHero\Drive\Drive($driveService);

Get the Google_Service_Drive instance

$drive->getService() // \Google_Service_Drive

Retrieve a file

$file = $drive->get('efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV');

echo get_class($file); // \Google_Service_Drive_DriveFile
echo $file->id; // 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV'

Set file permissions

$fileId = 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV';
$permissions = $drive->setPermission($fileId, 'anyone', 'reader');

echo get_class($permissions); // \Google_Service_Drive_Permission

Create a file

See mime types.

$file = $drive->create('My File', 'application/vnd.google-apps.file');

echo get_class($file); // \Google_Service_Drive_DriveFile
echo $file->id; // 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV'

Create a folder

$folder = $drive->createFolder('My Folder');

echo get_class($folder); // \Google_Service_Drive_DriveFile
echo $folder->id; // 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV'

Delete a file

$fileId = 'efTpcKY4TL2DWbExuvBuRxlmVFtsxpAeyHmMfxpwcobePxKV';

$drive->delete($fileId); // null

Testing

$ composer all

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email ryan@basecardhero.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

PHP Package Boilerplate

This package was generated using the PHP Package Boilerplate.