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

Flysystem is a filesystem abstraction for PHP that lets you read, write, and manage files through a unified API across local disks and cloud storage (S3, FTP, SFTP, etc.). Swap adapters without changing app code, with consistent paths, streams, and visibility.

View on GitHub
Deep Wiki
Context7

File storage abstraction for PHP

Frequently asked questions about Flysystem
How do I replace Laravel’s default filesystem with league/flysystem?
Extend Laravel’s `FilesystemServiceProvider` to register flysystem adapters in `config/filesystems.php`. For example, define an S3 disk with the `AwsS3Adapter` class and inject AWS credentials. Laravel’s `Storage` facade will then use flysystem under the hood without breaking existing code.
Can I use flysystem for both local and cloud storage in the same Laravel app?
Yes. Use Laravel’s `MountManager` to dynamically mount multiple filesystems (e.g., local, S3, FTP) under a single interface. This lets you switch between storage backends without changing business logic, ideal for hybrid setups.
Does league/flysystem support async file operations for AWS S3 in Laravel?
Yes, use the `AsyncAwsS3Adapter` with Laravel’s queue system to offload large file uploads or downloads. Configure it in a service provider and dispatch jobs for non-blocking operations, reducing timeouts and improving performance.
What Laravel versions are compatible with league/flysystem?
Flysystem works with Laravel 8.x through 11.x. For Laravel 10+, ensure you’re using flysystem 3.x (PHP 8.1+) or 2.x (PHP 7.4+). Check the [Laravel Filesystem docs](https://laravel.com/docs/filesystem) for adapter-specific requirements.
How do I generate signed URLs (e.g., S3 pre-signed URLs) with flysystem in Laravel?
Use flysystem’s built-in `publicUrl()` or `temporaryUrl()` methods on adapters like `AwsS3Adapter`. For S3, these methods integrate with AWS SDK to generate pre-signed URLs with custom expiry times, matching Laravel’s `Storage::disk()->url()` behavior.
Can I mock flysystem adapters in PHPUnit for testing?
Yes. Use PHPUnit’s mocking to replace adapters with test doubles. For example, mock `AwsS3Adapter` to simulate failed uploads or network timeouts. This is critical for testing edge cases like SFTP connection drops or S3 throttling.
What are the performance implications of using flysystem with remote storage (e.g., S3) in Laravel?
Remote adapters (e.g., S3, SFTP) introduce latency compared to local storage. Mitigate this by caching metadata with `CacheAdapter` or using Laravel’s queue system for async operations. Benchmark local vs. remote adapters to identify bottlenecks.
How do I handle adapter-specific errors (e.g., SFTP connection failures) in Laravel?
Wrap flysystem operations in try-catch blocks to handle adapter-specific exceptions. For SFTP, validate host fingerprints (new in flysystem 3.33.0) and implement retries with Laravel’s `retry` helper or a custom decorator.
Are there alternatives to league/flysystem for Laravel filesystem abstraction?
Laravel’s native `Storage` facade already uses flysystem under the hood for S3, FTP, and local storage. For advanced use cases, consider `spatie/laravel-medialibrary` (for Eloquent file attachments) or `intervention/image` (for image processing), but flysystem remains the most flexible for raw filesystem operations.
How do I configure flysystem to work with Google Cloud Storage (GCS) in Laravel?
Use the `GoogleCloudStorageAdapter` from flysystem’s GCS package. Register it in Laravel’s `config/filesystems.php` with your GCS credentials and bucket name. The adapter follows the same interface as S3, so existing Laravel `Storage` code will work without changes.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai