captjm/elfinderwidget-bundle
Installation
composer require captjm/elfinderwidget-bundle
Add to config/bundles.php:
Captjm\ElfinderWidgetBundle\CaptjmElfinderWidgetBundle::class => ['all' => true],
Configuration Publish the default config:
php artisan config:dump
Update config/packages/captjm_elfinder_widget.yaml with your storage path (e.g., public/uploads or a custom filesystem disk).
First Use Case Embed the widget in a Twig template:
{{ render(controller('CaptjmElfinderWidgetBundle:Default:index')) }}
Or use the standalone JS/CSS assets:
{{ asset('bundles/captjmelfinderwidget/js/elfinder.min.js') }}
File Manager Integration
textarea for file path input:
<textarea id="file-path-input" name="file_path"></textarea>
{{ render(controller('CaptjmElfinderWidgetBundle:Default:widget', {'target': 'file-path-input'})) }}
Custom Connector Configuration
Extend the default connector (PHP backend) by overriding the connector service:
# config/packages/captjm_elfinder_widget.yaml
captjm_elfinder_widget:
connector:
class: App\Services\CustomElfinderConnector
Implement Captjm\ElfinderWidgetBundle\Connector\ConnectorInterface.
Twig Extensions
Use the elfinder_widget Twig function for dynamic rendering:
{{ elfinder_widget({
'target': 'file-input',
'options': {'uploadMaxSize': 2097152} # 2MB limit
}) }}
Asset Management
php artisan vendor:publish --tag=elfinder-widget-assets
webpack.mix.js or manual asset compilation.Connector Misconfiguration
connector path in config/packages/captjm_elfinder_widget.yaml is correct (default: bundles/captjmelfinderwidget/connector.php).tail -f storage/logs/laravel.log if the connector fails silently.Filesystem Permissions
public/uploads) has 755 permissions and is writable by the web server user.filesystem config is properly set in config/filesystems.php.Twig Autoloading
php artisan cache:clear
php artisan config:clear
CSRF Protection
// app/Http/Middleware/VerifyCsrfToken.php
protected $except = [
'bundles/captjmelfinderwidget/connector',
];
Custom Commands Extend the bundle by creating a custom command to sync files or generate thumbnails:
// app/Console/Commands/SyncElfinder.php
use Captjm\ElfinderWidgetBundle\Services\ElfinderService;
$elfinder = app(ElfinderService::class);
$elfinder->syncDisk('public', 'uploads');
Event Listeners
Hook into file operations (e.g., post-upload) via the ElfinderEvents:
// app/Providers/EventServiceProvider.php
protected $listen = [
'Captjm\ElfinderWidgetBundle\Events\FileUploaded' => [
'App\Listeners\LogUploadedFile',
],
];
Localization Override translations by publishing the bundle’s language files:
php artisan vendor:publish --tag=elfinder-widget-translations
Performance
Net, FTP) in the connector config to reduce overhead.cache:tag to invalidate Twig cache when configs change:
php artisan cache:clear --tags=elfinder-widget
How can I help you explore Laravel packages today?