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

Flysystem Laravel Package

league/flysystem

League/Flysystem is a filesystem abstraction for PHP that provides a consistent API for local disks and cloud storage like S3. Swap adapters without changing your app, with support for reading/writing files, directories, visibility, and streams.

View on GitHub
Deep Wiki
Context7

league/flysystem is a robust filesystem abstraction for PHP that lets you work with local storage and cloud providers through a single, consistent API. It’s widely used in frameworks like Laravel to keep file operations portable, testable, and vendor-agnostic.

Swap adapters without rewriting application code, standardize common tasks (read/write/list), and build storage integrations that scale from local disks to distributed object stores.

  • Unified filesystem API across multiple storage backends
  • Adapter ecosystem for S3, FTP, SFTP, local, and more
  • Stream-based operations for efficient large file handling
  • Clear separation of concerns for clean architecture and testing
  • Extensible design to create custom adapters and plugins
Frequently asked questions about Flysystem
How do I integrate league/flysystem with Laravel’s default Storage facade?
Use Laravel’s service container to bind FlySystem’s Filesystem class to the filesystem key. For example, in `AppServiceProvider`, bind a LocalAdapter or cloud adapter (e.g., S3) to replace Laravel’s default filesystem. The Storage facade will then use FlySystem’s unified API without changes to your business logic.
Which Laravel versions are officially supported by league/flysystem?
FlySystem 3.x is compatible with Laravel 8.x, 9.x, and 10.x. For Laravel 7.x, use FlySystem 2.x. Always check the package’s Composer requirements and Laravel’s documentation for version-specific quirks, like filesystem disk configuration changes in newer Laravel releases.
Can I use FlySystem for large file uploads (e.g., videos) in Laravel?
Yes, FlySystem supports streaming large files via its `writeStream()` and `readStream()` methods. For Laravel, pair this with Symfony’s StreamedResponse or Laravel’s HTTP responses to avoid memory issues. Cloud adapters like S3 also support multipart uploads for efficiency.
How do I configure FlySystem to work with AWS S3 in Laravel?
Install `league/flysystem-aws-s3-laravel` and configure it in `config/filesystems.php` under the `disks` array. Use Laravel’s AWS credentials (from `.env`) and map the S3 adapter to a disk. FlySystem will handle the rest, including ACLs and region settings via Laravel’s binding system.
Is FlySystem thread-safe for concurrent file operations in Laravel queues?
FlySystem itself is thread-safe, but cloud adapters (e.g., S3) may have rate limits or require retries. Use Laravel’s queue workers with retry logic or implement a circuit breaker pattern for critical operations. For local storage, ensure filesystem locks are handled by your application logic.
How can I test FlySystem adapters in Laravel’s PHPUnit tests?
Mock FlySystem’s Filesystem or Adapter interfaces in your tests using PHPUnit’s mock builder. For example, create a fake adapter that records operations or returns canned responses. Laravel’s testing helpers (e.g., `Storage::fake()`) can also be extended to work with FlySystem adapters.
What are the performance implications of using FlySystem with remote storage (e.g., SFTP) in production?
Remote adapters like SFTP introduce latency compared to local storage. Optimize by caching metadata (e.g., `statCache` in FlySystem) and using connection pooling. For Laravel, consider async processing (queues) for non-critical operations and monitor adapter-specific metrics like connection timeouts.
Can FlySystem replace Laravel’s default filesystem entirely, or should I use it alongside?
FlySystem can fully replace Laravel’s filesystem by binding it to the `filesystem` key in the service container. However, for gradual adoption, use Laravel’s `Storage::disk()` method with FlySystem adapters for specific disks (e.g., `s3`, `gcs`). This avoids refactoring existing code that relies on Laravel’s default adapter.
Are there security risks when using FlySystem with cloud storage (e.g., S3 bucket policies)?
FlySystem itself doesn’t enforce security policies, but you can configure it to use IAM roles with least privilege, client-side encryption (SSE-C), or temporary URLs. For Laravel, validate credentials in `.env` and use FlySystem’s `temporaryUrl()` method with short TTLs for sensitive files. Always audit bucket policies separately.
What alternatives to league/flysystem exist for Laravel, and when should I consider them?
Alternatives include Laravel’s built-in filesystem (for simple local storage) or vendor-specific SDKs like AWS SDK for PHP (for deep S3 integration). Use FlySystem if you need multi-cloud support, testability, or a unified API. For lightweight projects, Laravel’s default filesystem may suffice, but FlySystem shines in complex, scalable, or multi-environment setups.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport