Display Google Drive into elFinder using flysystem
I want to create a google drive flysystem.
I create this app based Yii2, but I dont mind if you give me another solution in php.
Ok, so far, this what I've done.
composer require creocoder/yii2-flysystem
for the Flysystemcomposer require nao-pon/flysystem-google-drive:~1.1
for the Adapter
I create a configuration in config/web.php
'components' => [
'googleDrive' => [
'class' => 'appmodulessuperAdmincomponentsGoogleDriveFilesystem',
'clientId' => 'myIDHere',
'clientSecret' => 'secretHere',
'refreshToken' => 'tokenHere',
'rootFolderId' => ''
],
]
then this is the GoogleDriveFilesystem
that I extends from creocoderflysystemFilesystem;
namespace appmodulessuperAdmincomponents;
use creocoderflysystemFilesystem;
use elFinder;
use elFinderConnector;
use Google_Client;
use Google_Service_Drive;
use HypwebFlysystemGoogleDriveGoogleDriveAdapter;
use yiibaseInvalidConfigException;
class GoogleDriveFilesystem extends Filesystem
public $clientId;
public $clientSecret;
public $refreshToken;
public $rootFolderId;
public $adapter;
/**
* @inheritdoc
*/
public function init()
if ($this->clientId === null)
throw new InvalidConfigException('The "clientId" property must be set.');
if ($this->clientSecret === null)
throw new InvalidConfigException('The "clientSecret" property must be set.');
if ($this->refreshToken === null)
throw new InvalidConfigException('The "refreshToken" property must be set.');
parent::init();
/**
* @return GoogleDriveAdapter
*/
protected function prepareAdapter()
$client = new Google_Client();
$client->setClientId($this->clientId);
$client->setClientSecret($this->clientSecret);
$client->refreshToken($this->refreshToken);
$service = new Google_Service_Drive($client);
$this->adapter = new GoogleDriveAdapter($service, $this->rootFolderId, [
'useHasDir' => true
]);
return $this->adapter;
public function displayInElFinder()
$googleDrive = $this->adapter;
// Make Flysystem adapter and cache object
$useCache = true;
if ($useCache)
// Example to Flysystem cacheing
$cache = new LeagueFlysystemCachedStorageAdapter(
new LeagueFlysystemAdapterLocal('flycache'),
'gdcache',
300
);
// Flysystem cached adapter
$adapter = new LeagueFlysystemCachedCachedAdapter(
$googleDrive,
$cache
);
else
// Not use cached adapter
$cache = null;
$adapter = $googleDrive;
// Google Drive elFinder Volume driver
$gdrive = [
// require
'driver' => 'FlysystemExt',
'filesystem' => new LeagueFlysystemFilesystem($adapter),
'fscache' => $cache,
'separator' => '/',
'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();;
For the testing, I use
<?php $obj = Yii::$app->googleDrive;?>
<pre>
<?= yiihelperVarDumper::dumpAsString($obj->listContents()) ?>
</pre>
I got success one.
[
0 => [
'name' => 'Contoh BL'
'type' => 'dir'
'path' => '1oF2A4SVTGL3zq9XDRF7o2hIzZ66IFeFS'
'filename' => 'Contoh BL'
'extension' => ''
'timestamp' => 1542228118
'size' => 0
'hasdir' => false
'dirname' => ''
'basename' => '1oF2A4SVTGL3zq9XDRF7o2hIzZ66IFeFS'
]
]
But how to display them into elFinder,
I try like this,
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<?php $obj = Yii::$app->googleDrive; ?>
<?php $obj->displayInElFinder() ?>
</div>
</div>
I got error like this:
"error": [
"errUnknownCmd"
]
php yii2 elfinder flysystem-google-drive
add a comment |
I want to create a google drive flysystem.
I create this app based Yii2, but I dont mind if you give me another solution in php.
Ok, so far, this what I've done.
composer require creocoder/yii2-flysystem
for the Flysystemcomposer require nao-pon/flysystem-google-drive:~1.1
for the Adapter
I create a configuration in config/web.php
'components' => [
'googleDrive' => [
'class' => 'appmodulessuperAdmincomponentsGoogleDriveFilesystem',
'clientId' => 'myIDHere',
'clientSecret' => 'secretHere',
'refreshToken' => 'tokenHere',
'rootFolderId' => ''
],
]
then this is the GoogleDriveFilesystem
that I extends from creocoderflysystemFilesystem;
namespace appmodulessuperAdmincomponents;
use creocoderflysystemFilesystem;
use elFinder;
use elFinderConnector;
use Google_Client;
use Google_Service_Drive;
use HypwebFlysystemGoogleDriveGoogleDriveAdapter;
use yiibaseInvalidConfigException;
class GoogleDriveFilesystem extends Filesystem
public $clientId;
public $clientSecret;
public $refreshToken;
public $rootFolderId;
public $adapter;
/**
* @inheritdoc
*/
public function init()
if ($this->clientId === null)
throw new InvalidConfigException('The "clientId" property must be set.');
if ($this->clientSecret === null)
throw new InvalidConfigException('The "clientSecret" property must be set.');
if ($this->refreshToken === null)
throw new InvalidConfigException('The "refreshToken" property must be set.');
parent::init();
/**
* @return GoogleDriveAdapter
*/
protected function prepareAdapter()
$client = new Google_Client();
$client->setClientId($this->clientId);
$client->setClientSecret($this->clientSecret);
$client->refreshToken($this->refreshToken);
$service = new Google_Service_Drive($client);
$this->adapter = new GoogleDriveAdapter($service, $this->rootFolderId, [
'useHasDir' => true
]);
return $this->adapter;
public function displayInElFinder()
$googleDrive = $this->adapter;
// Make Flysystem adapter and cache object
$useCache = true;
if ($useCache)
// Example to Flysystem cacheing
$cache = new LeagueFlysystemCachedStorageAdapter(
new LeagueFlysystemAdapterLocal('flycache'),
'gdcache',
300
);
// Flysystem cached adapter
$adapter = new LeagueFlysystemCachedCachedAdapter(
$googleDrive,
$cache
);
else
// Not use cached adapter
$cache = null;
$adapter = $googleDrive;
// Google Drive elFinder Volume driver
$gdrive = [
// require
'driver' => 'FlysystemExt',
'filesystem' => new LeagueFlysystemFilesystem($adapter),
'fscache' => $cache,
'separator' => '/',
'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();;
For the testing, I use
<?php $obj = Yii::$app->googleDrive;?>
<pre>
<?= yiihelperVarDumper::dumpAsString($obj->listContents()) ?>
</pre>
I got success one.
[
0 => [
'name' => 'Contoh BL'
'type' => 'dir'
'path' => '1oF2A4SVTGL3zq9XDRF7o2hIzZ66IFeFS'
'filename' => 'Contoh BL'
'extension' => ''
'timestamp' => 1542228118
'size' => 0
'hasdir' => false
'dirname' => ''
'basename' => '1oF2A4SVTGL3zq9XDRF7o2hIzZ66IFeFS'
]
]
But how to display them into elFinder,
I try like this,
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<?php $obj = Yii::$app->googleDrive; ?>
<?php $obj->displayInElFinder() ?>
</div>
</div>
I got error like this:
"error": [
"errUnknownCmd"
]
php yii2 elfinder flysystem-google-drive
add a comment |
I want to create a google drive flysystem.
I create this app based Yii2, but I dont mind if you give me another solution in php.
Ok, so far, this what I've done.
composer require creocoder/yii2-flysystem
for the Flysystemcomposer require nao-pon/flysystem-google-drive:~1.1
for the Adapter
I create a configuration in config/web.php
'components' => [
'googleDrive' => [
'class' => 'appmodulessuperAdmincomponentsGoogleDriveFilesystem',
'clientId' => 'myIDHere',
'clientSecret' => 'secretHere',
'refreshToken' => 'tokenHere',
'rootFolderId' => ''
],
]
then this is the GoogleDriveFilesystem
that I extends from creocoderflysystemFilesystem;
namespace appmodulessuperAdmincomponents;
use creocoderflysystemFilesystem;
use elFinder;
use elFinderConnector;
use Google_Client;
use Google_Service_Drive;
use HypwebFlysystemGoogleDriveGoogleDriveAdapter;
use yiibaseInvalidConfigException;
class GoogleDriveFilesystem extends Filesystem
public $clientId;
public $clientSecret;
public $refreshToken;
public $rootFolderId;
public $adapter;
/**
* @inheritdoc
*/
public function init()
if ($this->clientId === null)
throw new InvalidConfigException('The "clientId" property must be set.');
if ($this->clientSecret === null)
throw new InvalidConfigException('The "clientSecret" property must be set.');
if ($this->refreshToken === null)
throw new InvalidConfigException('The "refreshToken" property must be set.');
parent::init();
/**
* @return GoogleDriveAdapter
*/
protected function prepareAdapter()
$client = new Google_Client();
$client->setClientId($this->clientId);
$client->setClientSecret($this->clientSecret);
$client->refreshToken($this->refreshToken);
$service = new Google_Service_Drive($client);
$this->adapter = new GoogleDriveAdapter($service, $this->rootFolderId, [
'useHasDir' => true
]);
return $this->adapter;
public function displayInElFinder()
$googleDrive = $this->adapter;
// Make Flysystem adapter and cache object
$useCache = true;
if ($useCache)
// Example to Flysystem cacheing
$cache = new LeagueFlysystemCachedStorageAdapter(
new LeagueFlysystemAdapterLocal('flycache'),
'gdcache',
300
);
// Flysystem cached adapter
$adapter = new LeagueFlysystemCachedCachedAdapter(
$googleDrive,
$cache
);
else
// Not use cached adapter
$cache = null;
$adapter = $googleDrive;
// Google Drive elFinder Volume driver
$gdrive = [
// require
'driver' => 'FlysystemExt',
'filesystem' => new LeagueFlysystemFilesystem($adapter),
'fscache' => $cache,
'separator' => '/',
'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();;
For the testing, I use
<?php $obj = Yii::$app->googleDrive;?>
<pre>
<?= yiihelperVarDumper::dumpAsString($obj->listContents()) ?>
</pre>
I got success one.
[
0 => [
'name' => 'Contoh BL'
'type' => 'dir'
'path' => '1oF2A4SVTGL3zq9XDRF7o2hIzZ66IFeFS'
'filename' => 'Contoh BL'
'extension' => ''
'timestamp' => 1542228118
'size' => 0
'hasdir' => false
'dirname' => ''
'basename' => '1oF2A4SVTGL3zq9XDRF7o2hIzZ66IFeFS'
]
]
But how to display them into elFinder,
I try like this,
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<?php $obj = Yii::$app->googleDrive; ?>
<?php $obj->displayInElFinder() ?>
</div>
</div>
I got error like this:
"error": [
"errUnknownCmd"
]
php yii2 elfinder flysystem-google-drive
I want to create a google drive flysystem.
I create this app based Yii2, but I dont mind if you give me another solution in php.
Ok, so far, this what I've done.
composer require creocoder/yii2-flysystem
for the Flysystemcomposer require nao-pon/flysystem-google-drive:~1.1
for the Adapter
I create a configuration in config/web.php
'components' => [
'googleDrive' => [
'class' => 'appmodulessuperAdmincomponentsGoogleDriveFilesystem',
'clientId' => 'myIDHere',
'clientSecret' => 'secretHere',
'refreshToken' => 'tokenHere',
'rootFolderId' => ''
],
]
then this is the GoogleDriveFilesystem
that I extends from creocoderflysystemFilesystem;
namespace appmodulessuperAdmincomponents;
use creocoderflysystemFilesystem;
use elFinder;
use elFinderConnector;
use Google_Client;
use Google_Service_Drive;
use HypwebFlysystemGoogleDriveGoogleDriveAdapter;
use yiibaseInvalidConfigException;
class GoogleDriveFilesystem extends Filesystem
public $clientId;
public $clientSecret;
public $refreshToken;
public $rootFolderId;
public $adapter;
/**
* @inheritdoc
*/
public function init()
if ($this->clientId === null)
throw new InvalidConfigException('The "clientId" property must be set.');
if ($this->clientSecret === null)
throw new InvalidConfigException('The "clientSecret" property must be set.');
if ($this->refreshToken === null)
throw new InvalidConfigException('The "refreshToken" property must be set.');
parent::init();
/**
* @return GoogleDriveAdapter
*/
protected function prepareAdapter()
$client = new Google_Client();
$client->setClientId($this->clientId);
$client->setClientSecret($this->clientSecret);
$client->refreshToken($this->refreshToken);
$service = new Google_Service_Drive($client);
$this->adapter = new GoogleDriveAdapter($service, $this->rootFolderId, [
'useHasDir' => true
]);
return $this->adapter;
public function displayInElFinder()
$googleDrive = $this->adapter;
// Make Flysystem adapter and cache object
$useCache = true;
if ($useCache)
// Example to Flysystem cacheing
$cache = new LeagueFlysystemCachedStorageAdapter(
new LeagueFlysystemAdapterLocal('flycache'),
'gdcache',
300
);
// Flysystem cached adapter
$adapter = new LeagueFlysystemCachedCachedAdapter(
$googleDrive,
$cache
);
else
// Not use cached adapter
$cache = null;
$adapter = $googleDrive;
// Google Drive elFinder Volume driver
$gdrive = [
// require
'driver' => 'FlysystemExt',
'filesystem' => new LeagueFlysystemFilesystem($adapter),
'fscache' => $cache,
'separator' => '/',
'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();;
For the testing, I use
<?php $obj = Yii::$app->googleDrive;?>
<pre>
<?= yiihelperVarDumper::dumpAsString($obj->listContents()) ?>
</pre>
I got success one.
[
0 => [
'name' => 'Contoh BL'
'type' => 'dir'
'path' => '1oF2A4SVTGL3zq9XDRF7o2hIzZ66IFeFS'
'filename' => 'Contoh BL'
'extension' => ''
'timestamp' => 1542228118
'size' => 0
'hasdir' => false
'dirname' => ''
'basename' => '1oF2A4SVTGL3zq9XDRF7o2hIzZ66IFeFS'
]
]
But how to display them into elFinder,
I try like this,
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<?php $obj = Yii::$app->googleDrive; ?>
<?php $obj->displayInElFinder() ?>
</div>
</div>
I got error like this:
"error": [
"errUnknownCmd"
]
php yii2 elfinder flysystem-google-drive
php yii2 elfinder flysystem-google-drive
asked Nov 15 '18 at 5:26
Fadly DzilFadly Dzil
8381540
8381540
add a comment |
add a comment |
0
active
oldest
votes
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312961%2fdisplay-google-drive-into-elfinder-using-flysystem%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312961%2fdisplay-google-drive-into-elfinder-using-flysystem%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown