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

Gaufrette Filesystem Bridge Laravel Package

bengor-file/gaufrette-filesystem-bridge

Bridge adapter that makes BenGorFile File objects work with a Gaufrette filesystem. Install via Composer, PHP 5.5+. Includes PHPSpec test suite and links to full documentation in the BenGorFile/File docs.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require bengor-file/gaufrette-filesystem-bridge
    

    Add to config/filesystems.php under disks:

    'gaufrette' => [
        'driver' => 'gaufrette',
        'adapter' => \BenGorFile\GaufretteFilesystemBridge\GaufretteAdapter::class,
        'options' => [
            'filesystem' => new \Gaufrette\Filesystem(new \Gaufrette\Adapter\Local('/path/to/storage')),
        ],
    ],
    
  2. First Use Case Replace Laravel’s default filesystem with Gaufrette for a specific disk:

    use Illuminate\Support\Facades\Storage;
    
    Storage::disk('gaufrette')->put('file.txt', 'Hello Gaufrette!');
    $contents = Storage::disk('gaufrette')->get('file.txt');
    
  3. Key Files to Review

    • config/filesystems.php (configuration)
    • GaufretteAdapter.php (core adapter logic)
    • GaufretteFilesystem.php (Laravel filesystem wrapper)

Implementation Patterns

Workflows

  1. Hybrid Storage Use Gaufrette for cloud/remote storage (e.g., S3, FTP) while keeping local files on Laravel’s default disk:

    // Upload to Gaufrette-backed S3
    Storage::disk('gaufrette_s3')->put('remote/file.jpg', file_get_contents('local.jpg'));
    
    // Fallback to local for static assets
    Storage::disk('local')->put('static/file.jpg', file_get_contents('local.jpg'));
    
  2. Dynamic Disk Binding Bind Gaufrette adapters dynamically based on environment:

    $adapter = new \Gaufrette\Adapter\Ftp('ftp.example.com', ['username' => 'user', 'password' => 'pass']);
    Storage::extend('ftp', function () use ($adapter) {
        return new \BenGorFile\GaufretteFilesystemBridge\GaufretteFilesystem(new \Gaufrette\Filesystem($adapter));
    });
    
  3. Streaming Large Files Leverage Gaufrette’s streaming capabilities for memory efficiency:

    $stream = Storage::disk('gaufrette')->readStream('large-video.mp4');
    // Process stream without loading entire file into memory
    

Integration Tips

  • Laravel Filesystem Events Gaufrette’s events (e.g., Gaufrette\Event\File\CreateEvent) can be hooked via Laravel’s Storage::dispatcher():

    Storage::disk('gaufrette')->dispatcher()->listen('file.created', function ($event) {
        Log::info("File created: {$event->getFile()->getKey()}");
    });
    
  • Custom Metadata Use Gaufrette’s metadata system to store additional file attributes:

    $filesystem = Storage::disk('gaufrette')->getFilesystem();
    $metadata = $filesystem->getMetadata('file.txt');
    $metadata->setCustomMetadata(['user_id' => 123]);
    $filesystem->setMetadata('file.txt', $metadata);
    
  • URL Generation Generate URLs via Gaufrette’s URI resolver (if supported by the underlying adapter):

    $uri = Storage::disk('gaufrette')->url('file.txt');
    

Gotchas and Tips

Pitfalls

  1. **
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony