Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Elfinder Flysystem Driver Ext Laravel Package

nao-pon/elfinder-flysystem-driver-ext

Extended Flysystem driver for elFinder (nao-pon/elfinder), adding broader filesystem adapter support to connect elFinder’s file manager to various storage backends through Flysystem, including extra/legacy adapters beyond the core driver.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require nao-pon/elfinder-flysystem-driver-ext
    

    Ensure league/flysystem and nao-pon/elfinder are also installed.

  2. Register the Driver In your config/elfinder.php, extend the Flysystem driver configuration:

    'drivers' => [
        'flysystem' => [
            'adapter' => \NaoPon\ElfinderFlysystemDriverExt\FlysystemDriver::class,
            'options' => [
                'root' => storage_path('app'),
                // Other Flysystem adapter options...
            ],
        ],
    ],
    
  3. First Use Case Initialize elFinder with the extended driver in a controller or blade view:

    use NaoPon\ElfinderFlysystemDriverExt\FlysystemDriver;
    
    $elfinder = new \Elfinder\Elfinder([
        'driver' => 'flysystem',
        'root' => storage_path('app'),
        'tmbPath' => storage_path('app/thumbs'),
    ]);
    

Implementation Patterns

Workflow Integration

  1. File Operations Leverage Flysystem’s capabilities (e.g., copy, move, delete) via elFinder’s UI:

    $elfinder->copy('source.txt', 'destination.txt');
    $elfinder->move('old.txt', 'new.txt');
    
  2. Custom Permissions Extend file permissions logic by overriding the driver’s isAccessible() or isReadable() methods:

    class CustomFlysystemDriver extends FlysystemDriver {
        public function isAccessible($path) {
            // Custom logic (e.g., check user roles)
            return parent::isAccessible($path);
        }
    }
    
  3. Thumbnail Generation Use the tmbPath config to auto-generate thumbnails for images:

    $elfinder->mkThumb('image.jpg', 150, 150);
    
  4. Event Listeners Hook into elFinder events (e.g., upload, delete) to sync with external systems:

    $elfinder->on('upload', function ($event) {
        // Sync to S3, log activity, etc.
    });
    

Gotchas and Tips

Pitfalls

  1. Driver Class Name Ensure the driver class (NaoPon\ElfinderFlysystemDriverExt\FlysystemDriver) is correctly referenced in config/elfinder.php. Typos here will cause silent failures.

  2. Flysystem Adapter Compatibility The extended driver assumes standard Flysystem adapters (e.g., Local, S3). Unsupported adapters may throw UnsupportedAdapterException.

  3. Thumbnail Paths If tmbPath is misconfigured, thumbnails will fail to generate. Verify the directory exists and is writable:

    mkdir -p storage/app/thumbs && chmod -R 775 storage/app/thumbs
    

Debugging

  • Enable Logging Add to config/elfinder.php:

    'debug' => true,
    

    Check storage/logs/laravel.log for driver-specific errors.

  • Check Adapter Initialization If files disappear or operations fail, validate the Flysystem adapter is properly initialized:

    $adapter = \League\Flysystem\Adapter\Local::class; // Example
    $this->adapter = new $adapter($this->options['root']);
    

Extension Points

  1. Override Driver Methods Extend the driver to add custom logic (e.g., file validation):

    class CustomDriver extends FlysystemDriver {
        public function upload($file, $path) {
            if (!$this->isAllowedFile($file)) {
                throw new \RuntimeException('File type not allowed.');
            }
            return parent::upload($file, $path);
        }
    }
    
  2. Add Custom Commands Use elFinder’s commands config to inject custom actions:

    'commands' => [
        'custom' => [
            'exec' => 'App\Elfinder\CustomCommand',
            'roles' => ['*'],
        ],
    ],
    
  3. Leverage Flysystem Events Tap into Flysystem’s events (e.g., preUpload, postDelete) for side effects:

    $adapter->addListener('preUpload', function ($event) {
        // Pre-process file before upload
    });
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor