1. Go to this page and download the library: Download dmstr/yii2-filefly-module library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dmstr / yii2-filefly-module example snippets
'filefly' => [
'class' => 'hrzg\filefly\Module',
'layout' => '@backend/views/layouts/main',
'filesystem' => getenv('AFM_FILESYSTEM'),
'slugNames' => (getenv('AFM_SLUG_NAMES')) ? getenv('AFM_SLUG_NAMES') : true,
'repair' => (getenv('AFM_REPAIR')) ? getenv('AFM_REPAIR') : true,
'deleteRecursive' => (getenv('AFM_DELETE_RECURSIVE')) ? getenv('AFM_DELETE_RECURSIVE') : false,
'streamExpireOffset' => 604800 # Offset (in seconds) for Expires Header in stream action
'defaultPermissions' => [
\hrzg\filefly\Module::ACCESS_OWNER => 1,
\hrzg\filefly\Module::ACCESS_READ => \hrzg\filefly\models\FileflyHashmap::$_all,
\hrzg\filefly\Module::ACCESS_UPDATE => \hrzg\filefly\models\FileflyHashmap::$_all,
\hrzg\filefly\Module::ACCESS_DELETE => \hrzg\filefly\models\FileflyHashmap::$_all,
],
# the urlCallbck property can be used to provide customized urls for each file item which (if defined) will overwrite
# the default handler URLs
'urlCallback' => function($item) {
$urls = [];
$isImageFileExtList = ['jpg', 'jpeg', 'gif', 'tiff', 'tif', 'svg', 'png', 'bmp'] ;
if ($item['type'] === 'file') {
if (in_array(strtolower($item['extension']), $isImageFileExtList)) {
$urls['image url'] = \dmstr\willnorrisImageproxy\Url::image($item['path']);
}
else {
$urls['download url'] = implode('/', ['/img/download', ltrim($item['path'], '/')]) . ',p1';
}
}
return $urls;
},
// previewCallback can be used to overwrite the default downloadUrl for preview URLs within filemanagerApp
'previewCallback' => function($item) {
$isImageFileExtList = ['jpg', 'jpeg', 'gif', 'tiff', 'tif', 'png', 'bmp'] ;
if ($item['type'] === 'file') {
if (in_array(strtolower($item['extension']), $isImageFileExtList)) {
return \dmstr\willnorrisImageproxy\Url::image($item['path'], '500x');
}
}
return '';
}
],