### Full Instance Configuration Example
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/README.md
A complete example of an instance configuration including multi-home folder settings and root definitions.
```yaml
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: 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 }
```
--------------------------------
### Install Flysystem Adapter
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/flysystem.md
Install the specific Flysystem adapter package required for the chosen storage backend.
```sh
composer require league/flysystem-aws-s3-v3
```
--------------------------------
### Install FMElfinderBundle
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/README.md
Use Composer to add the bundle to your project dependencies.
```sh
composer require helios-ag/fm-elfinder-bundle
```
--------------------------------
### Install Flysystem Driver
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/flysystem.md
Install the required elFinder Flysystem driver compatible with Flysystem v3.
```sh
composer require "barryvdh/elfinder-flysystem-driver:^0.5"
```
--------------------------------
### Enable community recipes for Symfony Flex
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/README.md
Required to allow installation of community-contributed bundles.
```sh
composer config extra.symfony.allow-contrib true
```
--------------------------------
### Bundle Configuration Prototype
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/configuration-dump.md
Use this YAML structure to define storage and database settings for the bundle. Ensure all required credentials are provided when enabling specific services.
```yaml
name: ~
dropbox2_settings:
enabled: false
app_key: ~
app_secret: ~
access_token: ~
aliasFormat: '%s@Dropbox'
path: /
separator: /
acceptedName: '%s@Dropbox'
rootCssClass: elfinder-navbar-root-dropbox
publishPermission:
requested_visibility: public
getThumbSize: medium
box_settings:
enabled: false
client_id: ~
client_secret: ~
accessToken: ~
root: Box.com
path: /
separator: /
tmbPath: ''
tmbURL: ''
tmpPath: ''
acceptedName: '#^[^/\?*:|"<>]*[^./\?*:|"<>]$#'
rootCssClass: elfinder-navbar-root-box
onedrive_settings:
enabled: false
client_id: ~
client_secret: ~
accessToken: ~
root: OneDrive.com
OneDriveApiClient: ''
path: /
separator: /
tmbPath: ''
tmbURL: ''
tmpPath: ''
acceptedName: '#^[^/\?*:|"<>]*[^./\?*:|"<>]$#'
rootCssClass: elfinder-navbar-root-onedrive
useApiThumbnail: true
ftp_settings:
enabled: false
host: ~
user: ~
password: ~
path: ~
mysql_settings:
enabled: false
host: ~
user: ~
pass: ~
db: ~
port: null
socket: null
files_table: elfinder_file
tmbPath: ''
tmpPath: ''
rootCssClass: elfinder-navbar-root-sql
noSessionCache: hasdirs
```
--------------------------------
### Configure StfalconTinymceBundle for TinyMCE 3.x
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/tinymce-integration.md
Add the file browser callback to the theme configuration.
```yaml
stfalcon_tinymce:
theme:
simple:
file_browser_callback : 'elFinderBrowser'
```
--------------------------------
### Import bundle routing
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/README.md
Add the bundle's routes to your application configuration.
```yaml
# app/config/routing.yaml
elfinder:
resource: "@FMElfinderBundle/Resources/config/routing.yaml"
```
--------------------------------
### Configure Multi-Home Folder Settings
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/README.md
Required configuration keys for enabling multi-home folder support in fm_elfinder.yaml.
```yaml
where_is_multi:
{connector}: {index of the connector}
multi_home_folder: true
folder_separator: {one char other of /}
```
--------------------------------
### Configure StfalconTinymceBundle for TinyMCE 4.x
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/tinymce-integration.md
Add the file browser callback to the theme configuration for version 4.x.
```yaml
stfalcon_tinymce:
theme:
simple:
file_browser_callback : elFinderBrowser
```
--------------------------------
### Configure a root with a service-driver
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/advanced-configuration.md
Use a service ID as the driver key within the fm_elfinder configuration to define a custom volume driver.
```yaml
fm_elfinder:
connector:
roots:
uploads:
driver: elfinder.driver.filesystem
path: uploads
```
--------------------------------
### Configure Flysystem Adapters in config.yml
Source: https://github.com/helios-ag/fmelfinderbundle/wiki/How-to-use-custom-filesystem-service-(flysystem-adapter)
Define custom adapters and filesystems within the oneup_flysystem configuration block.
```yaml
oneup_flysystem:
adapters:
adiuvo_cms_adapter_public:
rackspace:
lazy: true
container: adiuvo_cms.opencloud_public_container
filesystems:
adiuvo_cms_public:
adapter: adiuvo_cms_adapter_public
alias: filesystem_public
plugins:
- adiuvo_cms.flysystem.plugin.rackspace_public_url
```
--------------------------------
### Register bundle in AppKernel
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/README.md
Manual registration for Symfony projects not using Flex.
```php
{
var action = $('textarea').attr('browser-url');
var config = {
toolbar : 'Full',
uiColor : 'White',
filebrowserBrowseUrl : action+'?mode=file',
filebrowserImageBrowseUrl : action+'?mode=image',
filebrowserFlashBrowseUrl : action+'?mode=flash',
filebrowserImageWindowWidth : '950',
filebrowserImageWindowHeight : '520',
filebrowserWindowWidth : '950',
filebrowserWindowHeight : '520',
};
];
$('textarea#ckeditor').ckeditor(config);
})
////
```
--------------------------------
### Initialize Summernote in Template
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/summernote-integration.md
Add the initialization functions to the template containing the Summernote instance.
```jinja
{{ elfinder_summernote_init('instance_name') }}
{{ summernote_init() }}
```
--------------------------------
### Default fm_elfinder bundle configuration
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/configuration-dump.md
Reference for the full YAML configuration structure required to set up the fm_elfinder bundle.
```yaml
# Default configuration for extension with alias: "fm_elfinder"
fm_elfinder:
configuration_provider: fm_elfinder.configurator.default
assets_path: assets
loader: fm_elfinder.loader.default
instances: # Required
# Prototype
name:
locale: null
cors_support: false
editor: simple
editor_template: null
fullscreen: true
multi_home_folder: false
folder_separator: ''
theme: smoothness
tinymce_popup_path: ''
relative_path: true
path_prefix: /
where_is_multi: []
visible_mime_types: []
connector:
debug: false
binds:
# Prototype
name:
# Prototype
name: ~
plugins:
# Prototype
name:
# Prototype
name: ~
roots: # Required
# Prototype
name:
driver: ~ # Required
volume_id: 0
path: ''
autoload: false
phash: ''
trash_hash: ''
locale: ''
i18n_folder_name: false
mime_detect: auto
mimefile: ''
security_voter: ''
start_path: ''
encoding: UTF-8
url: ''
alias: ''
img_lib: auto
tmb_path: .tmb
tmb_path_mode: 511
tmb_url: ''
tmb_size: 48
tmb_crop: true
tmb_bg_color: '#ffffff'
quarantine: null
copy_overwrite: true
copy_join: true
copy_from: true
copy_to: true
upload_overwrite: true
fileMode: 420
upload_allow:
# Default:
- image
upload_deny:
# Default:
- all
upload_order:
# Defaults:
- deny
- allow
upload_max_size: 0
upload_max_conn: 3
defaults:
# Prototype
defaults: ~
attributes:
# Prototype
-
pattern: ~
read: true
write: true
locked: false
hidden: false
accepted_name: '/^\w[\w\s\.\%\-]*$/u'
show_hidden: false
disabled_commands: []
tree_deep: 0
check_subfolders: 1
separator: /
date_format: 'j M Y H:i'
time_format: 'H:i'
archive_mimes: []
archivers:
enabled: false
create:
# Prototype
-
cmd: ~
argc: ~
ext: ~
extract:
```
--------------------------------
### Reference a pre-configured Filesystem service
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/flysystem.md
Use an existing Flysystem v3 Filesystem service directly in the fm_elfinder configuration.
```yaml
fm_elfinder:
instances:
adapter:
locale: %locale%
editor: simple
connector:
roots:
uploads:
driver: Flysystem
flysystem:
filesystem: 'oneup_flysystem.my_filesystem'
path: ''
upload_allow: ['all']
```
--------------------------------
### Configure Custom Archivers
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/advanced-configuration.md
Define archive creation and extraction commands based on mime types within the instance configuration.
```yaml
fm_elfinder:
instances:
themes:
locale: %locale% # defaults to current request locale
cors_support: true
editor: simple
connector:
debug: true # defaults to false
roots: # at least one root must be defined
uploads:
driver: LocalFileSystem
path: %theme_root%
upload_allow: ['all']
upload_max_size: 10M
archive_mimes: "application/zip"
archivers:
create:
application/zip:
cmd: "phpfunction"
argc: "self::zipArchiveZip"
ext: "zip"
extract:
application/myzip:
cmd: "phpfunction"
argc: "self::zipArchiveUnzip"
ext: "zip"
```
--------------------------------
### Bundle Configuration Schema
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/configuration-dump.md
YAML structure defining the available configuration options for the bundle, including flysystem storage adapters and plugin settings.
```yaml
# Prototype
-
cmd: ~
argc: ~
ext: ~
flysystem:
enabled: false
filesystem: ''
type: ''
adapter_service: ''
options:
local:
enabled: false
path: ''
ftp:
enabled: false
host: ''
username: ''
password: ''
port: 21
passive: true
ssl: true
timeout: 30
root: /
directoryPerm: 484
sftp:
enabled: false
host: ''
username: ''
password: ''
port: 21
privateKey: ''
timeout: 10
root: /
aws_s3_v3:
enabled: false
key: ''
secret: ''
region: ''
version: ''
bucket_name: ''
optional_prefix: ''
endpoint: null
use_path_style_endpoint: false
use_aws_shared_config_files: true
options: []
dropbox:
enabled: false
app: ''
token: ''
glide_url: ''
glide_key: ''
plugins:
# Prototype
name:
# Prototype
name: ~
driver_options:
# Prototype
name:
```
--------------------------------
### Extend ElFinderConfigurationReader for Custom Adapters
Source: https://github.com/helios-ag/fmelfinderbundle/wiki/How-to-use-custom-filesystem-service-(flysystem-adapter)
Implement custom logic to resolve filesystem services by extending the configuration reader and checking for Filesystem or AdapterInterface instances.
```php
case 'custom':
$service = $this->container->get($serviceName);
if (is_object($service) && $service instanceof Filesystem) {
$filesystem = $service;
}
if (is_object($service) && $service instanceof AdapterInterface) {
$filesystem = new Filesystem($service);
}
break;
```
--------------------------------
### Configure Flysystem in YAML
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/flysystem.md
Define filesystem roots and driver options within the fm_elfinder configuration block.
```yaml
fm_elfinder:
instances:
default:
locale: %locale% # defaults to current request locale
editor: ckeditor # other options are tinymce, tinymce4, form, custom and simple
fullscreen: true # defaults true, applies to simple and ckeditor editors
connector:
debug: false # defaults to false
roots: # at least one root must be defined
local:
driver: Flysystem
path: uploads
flysystem:
type: local
options:
local:
path: %kernel.root_dir%/../web/uploads/
upload_allow: ['all']
#upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
#upload_deny: ['all']
upload_max_size: 2M
dropbox:
driver: Flysystem
path: uploads
flysystem:
type: dropbox
options:
dropbox:
token: ToKeN // can be aquired via developer console
upload_allow: ['all']
aws_s3:
driver: Flysystem
path: uploads
url: 'http://[my-bucket-name].s3.[region].amazonaws.com'
tmb_url: 'self' # For thumbnail generation on aws
flysystem:
type: aws_s3_v3
options:
aws_s3_v3:
version: 'latest'
key: 'MY_AWS_KEY'
secret: 'MY_AWS_SECRET'
region: 'MY_AWS_REGION'
bucket_name: 'MY_BUCKET_NAME'
# Optional default options forwarded to every S3 request
# performed by the adapter (e.g. ACL, StorageClass)
options:
ACL: 'public-read'
upload_allow: ['all']
```
--------------------------------
### Configure FOSCKEditorBundle
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/ckeditor-integration.md
Set the file browser route in settings.yml for FOSCKEditorBundle.
```yaml
fos_ck_editor:
default_config: default
configs:
default:
filebrowserBrowseRoute: elfinder
filebrowserBrowseRouteParameters: []
```
--------------------------------
### Initialize Elfinder for TinyMCE 3.x
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/tinymce-integration.md
Use the Twig helper to initialize the Elfinder instance alongside the TinyMCE editor.
```jinja
{{ elfinder_tinymce_init('instance_name', {'width':'900', 'height': '450', 'title':'ElFinder 2.0'}) }}
```
```jinja
{{ tinymce_init() }}
{{ elfinder_tinymce_init('instance_name') }}
```
--------------------------------
### Configure Elfinder Instance
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/elfinder-form-type.md
Define the Elfinder instance in your configuration file with the editor set to 'form'.
```yaml
fm_elfinder:
instances:
form:
locale: '%locale%' # defaults to current request locale
editor: form # other choices are tinymce or simple, and form
show_hidden: false # defaults to false
fullscreen: true # defaults true, applies to simple and ckeditor editors
connector:
debug: false # defaults to false
roots: # at least one root must be defined
uploads:
driver: LocalFileSystem
path: uploads
upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
upload_deny: ['all']
upload_max_size: 2M
```
--------------------------------
### Configure FMElfinderBundle for TinyMCE 3.x
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/tinymce-integration.md
Set the editor type and popup path in your application configuration.
```yaml
fm_elfinder:
editor: tinymce
tinymce_popup_path: "asset[bundles/stfalcontinymce/vendor/tiny_mce/tiny_mce_popup.js]"
```
--------------------------------
### Configure CORS Headers with NelmioCORSBundle
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/cors-support.md
Define the allowed origins, headers, and methods for the connector path to enable cross-domain access.
```yaml
# app/config/config.yml
nelmio_cors:
defaults:
allow_credentials: false
allow_origin: []
allow_headers: []
allow_methods: []
expose_headers: []
max_age: 0
hosts: []
paths:
'^/efconnect':
allow_origin: ['*']
allow_headers: ['X-Custom-Auth', 'Content-Type', 'X-Requested-With']
allow_methods: ['POST', 'GET', 'PATCH', 'PUT', 'DELETE']
max_age: 3600
allow_credentials: true
```
--------------------------------
### EasyAdmin 2.x Integration
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/elfinder-form-type.md
Configure the property type and form theme for EasyAdmin 2.x.
```yaml
- { property: 'images', type: 'collection', label: 'Images', type_options: { allow_add: false, allow_delete: false, entry_type: 'FM\ElfinderBundle\Form\Type\ElFinderType' }}
```
```yaml
design:
form_theme:
- '@EasyAdmin/form/bootstrap_4.html.twig'
- '@FMElfinder/Form/elfinder_widget.html.twig'
```
--------------------------------
### Implement a post-execution event listener
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/events-listeners-subscribers.md
This listener handles the post-execution event, allowing for conditional logic and the execution of sub-requests.
```php
// src/AppBundle/EventListener/ElFinder/PostExecutionListener.php
namespace AppBundle\EventListener\ElFinder;
use FM\ElfinderBundle\Event\ElFinderPostExecutionEvent;
class PostExecutionListener
{
/**
* @param ElFinderPostExecutionEvent $event
*/
public function onPostExecute(ElFinderPostExecutionEvent $event)
{
if (!$event->hasErrors() && $event->getCommand() == 'tmb') { // 'tmb', 'mkdir', 'open', etc...
// do your stuff here
// ...
// you can perform a sub request
$queryParameters = $event->getRequest()->query->all(); // getting original request parameters
$queryParameters['cmd'] = 'info'; // changing the command to execute in sub request
$jsonResponse = $event->subRequest(array(
'instance' => $event->getInstance(), // you can also make a subrequest on an other instance
'homeFolder' => $event->getHomeFolder() // and an other homeFolder
), $queryParameters);
$data = json_decode($jsonResponse->getContent());
// work with sub request data
// ...
}
}
}
```
--------------------------------
### Initialize Elfinder for TinyMCE 4.x
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/tinymce-integration.md
Initialize the Elfinder instance before the TinyMCE editor call.
```jinja
{{ elfinder_tinymce_init4('instance_name') }}
{{ tinymce_init() }}
```
--------------------------------
### Override Configuration Provider
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/advanced-configuration.md
Configure the bundle to use a custom service for reading configuration from the DIC.
```yaml
fm_elfinder:
configuration_provider: elfinder.configurator
```
```yaml
services:
my_elfinder_configurator:
class: Acme\DemoBundle\MyElfinderConfigurator
arguments: ["%my_arguments%"]
```
--------------------------------
### Publish elfinder assets
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/README.md
Copies the necessary assets to the public directory.
```sh
bin/console elfinder:install
```
--------------------------------
### Define a custom Flysystem adapter service
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/flysystem.md
Configure a local adapter as a service in your Symfony services configuration.
```yaml
services:
local_adapter:
class: League\Flysystem\Local\LocalFilesystemAdapter
arguments: ["%kernel.project_dir%/public/uploads/"]
```
--------------------------------
### Configure TrsteelCKEditorBundle
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/ckeditor-integration.md
Set the file browser URL in settings.yml for TrsteelCKEditorBundle.
```yaml
trsteel_ckeditor:
...
filebrowser_image_browse_url:
route: elfinder
route_parameters:
instance: ckeditor
```
--------------------------------
### Define a volume driver service
Source: https://github.com/helios-ag/fmelfinderbundle/blob/main/docs/advanced-configuration.md
Register the volume driver as a Symfony service using the appropriate class implementation.
```xml