ElFinder integration in Symfony
| Tests | Coverage | License | Version |
|---|---|---|---|
| Downloads |
|---|
elFinder is an open-source file manager for web, written in JavaScript using jQuery UI. Creation is inspired by simplicity and convenience of Finder program used in Mac OS X operating system.
Recommended bundles to use with:
| FMTinyMCEBundle | FOSCKEditorBundle | FMSummernoteBundle |
|---|---|---|
Table of contents
For Symfony Flex installation you need to enable community recipes:
composer config extra.symfony.allow-contrib true
Install the bundle:
composer require helios-ag/fm-elfinder-bundle
Prepare the elFinder assets inside the bundle, then publish them with Symfony:
bin/console elfinder:install
bin/console assets:install public
The order is important: elfinder:install assembles the bundle's upstream and
integration assets, then assets:install copies or symlinks them into
public/bundles/fmelfinder. Pass a different target directory or --symlink to
Symfony's assets:install command when needed.
For Composer auto-scripts, keep the same order in the application composer.json:
{
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"elfinder:install": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
}
}
}
Create the local upload directory used by the basic configuration below:
mkdir -p public/uploads
Make sure the PHP and web-server users have the required read and write
permissions for public/uploads.
Enable the bundle in the kernel (not needed with symfony flex):
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new FM\ElfinderBundle\FMElfinderBundle(),
);
}
# app/config/routing.yaml
elfinder:
resource: "@FMElfinderBundle/Resources/config/routing.yaml"
The default file-manager instance is now available at /elfinder; its connector
endpoint is /efconnect.
Secure ElFinder with access_control:
# app/config/security.yaml
security:
# ...
access_control:
- { path: ^/efconnect, roles: ROLE_USER }
- { path: ^/elfinder, roles: ROLE_USER }
fm_elfinder:
# Matches public/bundles/fmelfinder published by assets:install.
assets_path: /
instances:
default:
locale: '%locale%' # defaults to current request locale
editor: ckeditor # other options are tinymce, tinymce4, tinymce5, 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: '%kernel.project_dir%/public/uploads'
url: /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 }
/ value matches the default public/bundles/fmelfinder destination created by Symfony's assets:install.%kernel.project_dir%/public/uploads and make sure it has the required read/write and owner permissions./uploads. It can also be an absolute URL and may contain a {homeFolder} placeholder. If omitted, the bundle derives the URL from path, so setting it explicitly is recommended when path is an absolute filesystem path.You can see the full list of roots options here. To use them, convert camelCased option name to snake_case name.
You can set multiple upload root folder by instance configuration.
If you have configured your instance with /uploads path, you can provide
an additional folder as a home folder (e.g. for a multi-users application) when accessing to the instance URL :
/elfinder/{instance}/{homeFolder} or /efconnect/{instance}/{homeFolder}
For example, accessing to /elfinder/acmeInstance/bob URL will open up elfinder with
/uploads/bob as root directory which only contains Bob's files.
Then, accessing to /elfinder/acmeInstance/alice URL will re-use your instance,
but open up elfinder with /uploads/alice folder as root directory, containing only Alice's files.
To use this feature, you must provide the instance name in the URL, and of course be sure to set proper write/read permissions on home folders.
Note: this feature is only available with LocalFileSystem driver.
Yes you can with this configuration in your fm_elfinder.yaml
where_is_multi:
{connector}: {index of the connector}
multi_home_folder: true
folder_separator: {one char other of /}
fm_elfinder:
instances:
default:
locale: fr # defaults to current request locale
editor: ckeditor # other options are tinymce, tinymce4, tinymce5, fm_tinymce, form, simple, custom
#editor_template: custom template for your editor # default null
#path_prefix: http://localhost/ # 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 }
How can I help you explore Laravel packages today?