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

Filesystem Laravel Package

symfony/filesystem

Symfony Filesystem provides practical, cross-platform filesystem utilities for PHP: create/copy/move/remove files and directories, check existence, handle permissions, and more. Part of the Symfony Components with solid documentation and community support.

View on GitHub
Deep Wiki
Context7

Provides basic utilities for the filesystem

Frequently asked questions about Filesystem
How do I install Symfony Filesystem in a Laravel project?
Run `composer require symfony/filesystem` in your project root. The package is framework-agnostic but integrates seamlessly with Laravel’s dependency injection. No additional Laravel-specific setup is required beyond requiring the package.
Does Symfony Filesystem support Laravel’s multi-environment deployments (e.g., Docker, shared hosting)?
Yes. The package normalizes path separators and handles permissions cross-platform, making it ideal for Laravel deployments on Windows (Azure/AWS), Linux, or macOS. It resolves inconsistencies like `isAbsolute()` logic that break in mixed environments.
Can I use this with Laravel’s Storage facade or Flysystem?
Absolutely. Use Symfony Filesystem for low-level tasks (e.g., recursive directory operations) while keeping Flysystem or Laravel’s Storage facade for cloud/adapter-specific logic. For example, wrap Flysystem adapters with `symfony/filesystem` for hybrid workflows.
What Laravel versions and PHP versions does this package support?
The latest Symfony Filesystem (v8.x) requires PHP 8.4+, aligning with Laravel 10+. For Laravel 9/8 (PHP 8.2+), use Symfony 7.x. Check the [Symfony docs](https://symfony.com/doc/current/components/filesystem.html) for version-specific notes.
How do I integrate this into an Artisan command for cross-platform reliability?
Inject the `Filesystem` class into your command’s constructor, then use methods like `mirror()`, `remove()`, or `atomicWrite()`. Example: `public function handle(Filesystem $fs) { $fs->remove(storage_path('logs/old')); }`. This ensures consistent behavior across Windows/Linux.
Are there performance concerns with Symfony Filesystem vs. native PHP functions?
No significant overhead. Benchmarks show negligible differences between `symfony/filesystem` and native PHP (`file_exists()`, `mkdir()`). The package’s abstractions add minimal runtime cost while fixing edge cases (e.g., Windows path bugs).
How do I handle race conditions when writing critical files (e.g., config, cache)?
Use `atomicWrite()` to prevent partial writes. Example: `$fs->atomicWrite('/path/to/config.json', $data)`. This is critical for CLI/Artisan commands where concurrent processes might corrupt files during deployments or backups.
What’s the best way to replace custom path-handling logic in Laravel with this package?
Replace `str_replace('\', '/', $path)` with `Path::makeAbsolute($path)` or `Path::normalize($path)`. Register the `Filesystem` class as a singleton in `AppServiceProvider` for global access, then inject it into services/controllers.
Does this package fix Windows-specific path bugs in Laravel (e.g., backslashes in Azure/AWS)?
Yes. It resolves issues like `isAbsolute()` failing on Windows paths or backslash handling in v8.0.9. Test on Windows Server 2022 + WSL2 to validate fixes for your deployment environment. The package’s path normalization layer handles these edge cases.
Are there alternatives to Symfony Filesystem for Laravel filesystem tasks?
For basic tasks, Laravel’s native `Storage` facade or `File` helper suffice. For advanced cross-platform needs, consider Spatie’s `laravel-filesystem` or Flysystem adapters. However, Symfony Filesystem is lighter (~1MB) and integrates better with Symfony’s ecosystem if you’re already using other Symfony components.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony