Skip to content

Instantly share code, notes, and snippets.

@deividaspetraitis
Created October 19, 2017 09:36
Show Gist options
  • Save deividaspetraitis/4cca4fa6a61cc9a75e12f640041e53f5 to your computer and use it in GitHub Desktop.
Save deividaspetraitis/4cca4fa6a61cc9a75e12f640041e53f5 to your computer and use it in GitHub Desktop.
Lumen flysystem ( filesystem ) integration

Lumen flysystem integration

By default lumen doesn't support laravel file system. In order to integrate to lumen we need follow these instructions:

  1. composer require league/flysystem
  2. Copy filesystems config file from Laravel ( https://github.com/laravel/laravel/blob/master/config/filesystems.php ) to your local Lumen installation document_root/config
  3. Bind filesystem to IoC for example in document_root/bootstrap/app.php by adding this code lines:

$app->singleton('filesystem', function ($app) { return $app->loadComponent('filesystems', 'Illuminate\Filesystem\FilesystemServiceProvider', 'filesystem'); });

From now you should be able to access filesystem by calling app('filesystem') and use it as using in Laravel.

@iFrancs
Copy link

iFrancs commented Dec 4, 2020

League Flysystem V2 doesn't work with Lumen v8.x so use this
composer require "league/flysystem: ~1.0"

@rulatir
Copy link

rulatir commented Jul 25, 2021

Neither in the filesystems.php config file nor in any of the code snippets in your instruction do I find any reference to the Flysystem namespace. How does this solution actually ACCOMPLISH binding Flysystem as a filesystem provider/service/driver/adapter/whatever in Lumen?

Is it the case that the use of Flysystem is actually (hard)coded into Illuminate\Filesystem\FilesystemServiceProvider, but this provider itself isn't brought to life in a Lumen app by default? I've been struggling to understand what EXACTLY the relationship between Illuminate\Filesystem and League\Flysystem is.

Or is it the case that edits to the config/filesystems.php are necessary beyond just copying it - edits that would have to be done in full Laravel too, and are perhaps documented elsewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment