2017 © Pedro Peláez
 

library flysystem-google-drive

Flysystem adapter for Google Drive

image

nao-pon/flysystem-google-drive

Flysystem adapter for Google Drive

  • Friday, June 15, 2018
  • by nao-pon
  • Repository
  • 10 Watchers
  • 118 Stars
  • 86,746 Installations
  • PHP
  • 12 Dependents
  • 2 Suggesters
  • 38 Forks
  • 4 Open issues
  • 16 Versions
  • 21 % Grown

The README.md

Flysystem Adapter for Google Drive

Author Software License, (*1)

Installation

  • For Google Drive API V3
composer require nao-pon/flysystem-google-drive:~1.1
  • For Google Drive API V2 "Deprecated"
composer require nao-pon/flysystem-google-drive:~1.0.0

Usage

Follow Google Docs to obtain your ClientId, ClientSecret & refreshToken in addition you can also check this easy-to-follow tutorial

$client = new \Google_Client();
$client->setClientId('[app client id].apps.googleusercontent.com');
$client->setClientSecret('[app client secret]');
$client->refreshToken('[your refresh token]');

$service = new \Google_Service_Drive($client);

$adapter = new \Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter($service, '['root' or folder ID]');
/* Recommended cached adapter use */
// $adapter = new \League\Flysystem\Cached\CachedAdapter(
//     new \Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter($service, '['root' or folder ID]'),
//     new \League\Flysystem\Cached\Storage\Memory()
// );

$filesystem = new \League\Flysystem\Filesystem($adapter);

Usage to with elFinder

composer require nao-pon/elfinder-flysystem-driver-ext
composer require nao-pon/flysystem-google-drive:~1.1
// Load composer autoloader
require 'vender/autoload.php';

// Google API Client
$client = new \Google_Client();
$client->setClientId('xxxxx CLIENTID xxxxx');
$client->setClientSecret('xxxxx CLIENTSECRET xxxxx');
$client->refreshToken('xxxxx REFRESH TOKEN xxxxx');

// Google Drive Adapter
$googleDrive = new \Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter(
    new \Google_Service_Drive($client), // Client service
    'root',                             // Folder ID as root ('root' or Folder ID)
    [ 'useHasDir' => true ]             // options (elFinder need hasDir method)
);

// Extended cached strage adapter class for cache enabled of hasDir() method
class myCachedStrageAdapter extends \League\Flysystem\Cached\Storage\Adapter
{
    use \Hypweb\Flysystem\Cached\Extra\Hasdir;
    use \Hypweb\Flysystem\Cached\Extra\DisableEnsureParentDirectories;
}

// Make Flysystem adapter and cache object
$useCache = true;
if ($useCache) {
    // Example to Flysystem cacheing
    $cache = new myCachedStrageAdapter(
        new \League\Flysystem\Adapter\Local('flycache'),
        'gdcache',
        300
    );

    // Flysystem cached adapter
    $adapter = new \League\Flysystem\Cached\CachedAdapter(
        $googleDrive,
        $cache
    );
} else {
    // Not use cached adapter
    $cache = null;
    $adapter = $googleDrive;
}

// Google Drive elFinder Volume driver
$gdrive = [
    // require
    'driver'       => 'FlysystemExt',
    'filesystem'   =>  new \League\Flysystem\Filesystem($adapter),
    'fscache'      => $cache,
    'separator'    => '/',
    // optional
    'alias'        => 'GoogleDrive',
    'rootCssClass' => 'elfinder-navbar-root-googledrive'
];

// elFinder volume roots options
$elFinderOpts = [
    'roots' => []
];

$elFinderOpts['roots'][] = $gdrive;

// run elFinder
$connector = new elFinderConnector(new elFinder($elFinderOpts));
$connector->run();

Tips

TODO

  • Unit tests to be written

The Versions

15/06 2018

dev-master

9999999-dev

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

17/05 2018

1.1.9

1.1.9.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

24/04 2018

1.1.8

1.1.8.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

24/02 2018

1.1.7

1.1.7.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

18/08 2017

1.1.6

1.1.6.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

14/07 2017

1.1.5

1.1.5.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

07/04 2017

1.1.4

1.1.4.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

07/04 2017

dev-api_v2

dev-api_v2

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

07/04 2017

1.0.3

1.0.3.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

23/09 2016

1.1.3

1.1.3.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

19/07 2016

1.1.2

1.1.2.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

01/04 2016

1.1.1

1.1.1.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

11/03 2016

1.1.0

1.1.0.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

11/03 2016

1.0.2

1.0.2.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

23/02 2016

1.0.1

1.0.1.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires

17/02 2016

1.0.0

1.0.0.0

Flysystem adapter for Google Drive

  Sources   Download

MIT

The Requires

 

The Development Requires