alxishin / fm-elfinder-bundle
ElFinder 扩展包,将 ElFinder 文件管理器添加到您的 Symfony 项目中
Requires
- php: ^7.2 || ^8.0
- ext-json: *
- studio-42/elfinder: ~2.1
- symfony/asset: ^4.4 || ^5.0 || ^5.2
- symfony/flex: 1.*
- symfony/form: ^4.4 || ^5.0 || ^5.2
- symfony/framework-bundle: ^4.4 || ^5.0 || ^5.2
- symfony/twig-bundle: ^4.4 || ^5.0 || ^5.2
Requires (Dev)
- matthiasnoback/symfony-config-test: ^4.0
- matthiasnoback/symfony-dependency-injection-test: ^4.1
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^8.5
- symfony/finder: ^4.4 || ^5.0 || ^5.2
- symfony/phpunit-bridge: ^4.1 || ^5.0 || ^5.2
Suggests
- barryvdh/elfinder-flysystem-driver: Flysystem driver for elfinder
- friendsofsymfony/ckeditor-bundle: FOSCKEditorBundle WYSIWYG Editor Bundle
- helios-ag/fm-summernote-bundle: FMSummernoteBundle WYSIWYG Editor Bundle
- helios-ag/fm-tinymce-bundle: FMTinyMCEBundle WYSIWYG Editor Bundle
- spatie/flysystem-dropbox: Dropbox 2 Driver for Flysystem
- 10.1.0.3
- 10.1.0.2
- 10.1.0.1
- 10.1
- dev-master / 10.0.x-dev
- 10.0.4
- 10.0.3
- 10.0.2
- 10.0.1
- 10
- 9.3.2
- 9.3.1
- 9.3
- 9.2.1
- 9.2
- 9.1.1
- 9.1
- 9
- 8.0.3
- 8.0.2
- 8.0.1
- 8.0
- 7.0.1
- 7.0
- 6.2.1
- 6.2
- 6.1.2
- 6.1.1
- 6.1
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0
- 5.3
- 5.2.1
- 5.2
- 5.1
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 5
- 4.0.2
- 4.0.1
- 4.0
- 3.4
- 3.3
- 3.2.1
- 3.2
- 3.1
- 3.0
- 2.5.1
- 2.5
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.1
- v2.0
- 1.5
- 1.4.2
- 1.4.1
- 1.4
- 1.3
- 1.2
- 1.1
- 1.0
- dev-dependabot/composer/symfony/twig-bundle-tw-4.4.x-dev
- dev-dependabot/composer/symfony/asset-tw-4.4.x-dev
- dev-dependabot/composer/symfony/form-tw-4.4.x-dev
- dev-dependabot/composer/symfony/finder-tw-4.4.x-dev
- dev-dependabot/composer/symfony/framework-bundle-tw-4.4.x-dev
- dev-command-test
This package is auto-updated.
Last update: 2024-09-23 16:36:52 UTC
README
ElFinder 在 Symfony 中的集成
代码质量保证
elFinder 是一个基于 JavaScript 和 jQuery UI 的开源网络文件管理器。它的设计灵感来源于 Mac OS X 操作系统中使用的 Finder 程序的简洁性和便捷性。
推荐搭配使用的扩展包
目录
安装
步骤 1:安装
对于 Symfony Flex 安装,您需要启用社区食谱
composer config extra.symfony.allow-contrib true
安装
composer require helios-ag/fm-elfinder-bundle
将 elfinder 资产复制到公共文件夹
bin/console elfinder:install
步骤 2:启用扩展包(可选)
在内核中启用扩展包(与 symfony flex 一起使用时不需要)
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new FM\ElfinderBundle\FMElfinderBundle(), ); }
步骤 3:导入 FMElfinderBundle 路由文件
# app/config/routing.yaml elfinder: resource: "@FMElfinderBundle/Resources/config/routing.yaml"
步骤 4:配置您的应用程序的 security.yaml
使用 access_control 保护 ElFinder
# app/config/security.yaml security: //.... access_control: - { path: ^/efconnect, role: ROLE_USER } - { path: ^/elfinder, role: ROLE_USER }
基本配置
将配置选项添加到您的 config.yaml
fm_elfinder: #assets_path: / # default is /assets, this is where css/js elfinder files are instances: default: locale: '%locale%' # defaults to current request locale editor: ckeditor # other options are tinymce, tinymce4, fm_tinymce, form, simple, custom relative_path: false #default true, will produce absolute urls to specified file(s) #editor_template: custom template for your editor # default null #path_prefix: / # for setting custom assets path prefix, useful for non vhost configurations, i.e. http://127.0.0.1/mysite/ #fullscreen: true|false # default is true, applies to simple and ckeditor editors #theme: smoothness # jquery theme, default is 'smoothness' #visible_mime_types: ['image/png', 'image/jpg', 'image/jpeg'] # only show these mime types, defaults to show all connector: #debug: true|false # defaults to false roots: # at least one root must be defined, defines root filemanager directories uploads: #show_hidden: true|false # defaults to false, hides dotfiles driver: LocalFileSystem path: uploads upload_allow: ['image/png', 'image/jpg', 'image/jpeg'] upload_deny: ['all'] upload_max_size: 2M # also file upload sizes restricted in php.ini #attributes: example of setting attributes permission # - { pattern: '/(.*?)/', read: true, write: false, locked: true }
- default - elfinder 的实例,可以用于定义多个 ElFinder 配置,允许为项目中的不同类型的 WYSIWYG 编辑器同时进行配置
- path - 定义 web/ 目录内文件的根目录,默认为 "uploads"。请确保为此目录设置正确的读写和所有者权限。
- url - 要添加到图像路径的前缀 URL,用于显示。可以是
absolute
或relative
。如果是绝对路径,可以使用{homeFolder}
字符串作为占位符,它将被自动替换。如果是相对路径,它将与应用程序的基础 URL 前缀。如果为空,URL 将是基础 URL,后缀为 'path' 参数的值 - driver - 可以是 LocalFileSystem、FTP 或 MySQL、Flysystem、S3 等,请参阅 FM\ElfinderBundle\DependencyInjection\Configuration 类
- locale - 区域设置决定了 ElFinder 将使用哪种语言来翻译用户界面,默认为当前请求的区域设置
- cors_support - 允许处理跨域响应(默认为 false)
- editor - 确定要渲染的模板,以便与 WYSIWYG 网页编辑器兼容,目前支持以下选项:"ckeditor"(用于 FOSCKEditorBundle 或 TrsteelCkeditorBundle)、"fm_tinymce"(用于 tinymce4,与 FMTinyMCEBundle 一起使用)、"form"(用于表单类型)、"simple"(独立使用)和 "custom"(自定义模板)。如何配置 CKEDitor 和 TinyMCE 以与该扩展包一起使用,将在本文件的后续部分进行说明。
- editor_template - 当编辑器设置为 "custom" 时,定义要渲染的模板。
- connector - 定义 elfinder 根目录选项的根节点。
- roots - 定义 "虚拟目录",它反映了您项目中的目录。
- path_prefix - 使用 relative_path 启用时,路径前缀,默认为斜杠 ('/')
- show_hidden - 显示以 .(点)开头的文件和文件夹
- 驱动器 - 驱动器类型,LocalFileSystem,Dropbox,FTP
- volume_id - (可选) 在挂载卷时可以用来强制指定卷ID(默认自动递增)。如果提供,它必须是一个大于0的整数。
- alias - 目录别名
- path - 包含文件的目录
- upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
- upload_deny: ['all']
- upload_max_size: 2M
您可以在此处查看完整的根选项列表。要使用它们,请将驼峰命名法选项名称转换为蛇形命名法。
通过实例使用多个上传文件夹
您可以通过实例配置设置多个上传根文件夹。
如果您已将实例配置为/uploads
路径,您可以在访问实例URL时提供一个附加文件夹作为主文件夹(例如,用于多用户应用程序):
/elfinder/{instance}/{homeFolder}
或 /efconnect/{instance}/{homeFolder}
例如,访问/elfinder/acmeInstance/bob
URL将打开elfinder,以/uploads/bob
作为根目录,其中只包含Bob的文件。
然后,访问/elfinder/acmeInstance/alice
URL将重用您的实例,但将以/uploads/alice
文件夹作为根目录打开elfinder,其中只包含Alice的文件。
要使用此功能,您必须在URL中提供实例名称,并确保在主文件夹上设置适当的读写权限。
注意:此功能仅在LocalFileSystem
驱动程序中可用。
如果我想使用多个主文件夹呢?
是的,您可以通过在fm_elfinder.yaml中的此配置来实现:
where_is_multi: {connector}: {连接器的索引} multi_home_folder: true folder_separator: {一个字符的其他/}
示例
fm_elfinder:
instances:
default:
locale: fr # defaults to current request locale
editor: ckeditor # other options are tinymce, tinymce4, fm_tinymce, form, simple, custom
#editor_template: custom template for your editor # default null
#path_prefix: https:/// # for setting custom assets path prefix, useful for non vhost configurations, i.e. http://127.0.0.1/mysite/
fullscreen: false # default is true, applies to simple and ckeditor editors
where_is_multi:
roots: 0
multi_home_folder: true
folder_separator: "|"
#theme: smoothness # jquery theme, default is 'smoothness'
#visible_mime_types: ['image/png', 'image/jpg', 'image/jpeg'] # only show these mime types, defaults to show all
connector:
#debug: true|false # defaults to false
roots: # at least one root must be defined, defines root filemanager directories
uploads:
#show_hidden: true|false # defaults to false, hides dotfiles
driver: LocalFileSystem
path: "/var"
alias: Bibliothèque générale
upload_allow: ['all']
#upload_deny: ['all']
upload_max_size: 500M # also file upload sizes restricted in php.ini
attributes:
- {pattern: '..', read: true, write: true, locked: false}
#attributes: example of setting attributes permission
# - { pattern: '/(.*?)/', read: true, write: false, locked: true }