m2mtech/flysystem-stream-wrapper
Composer 安装命令:
composer require m2mtech/flysystem-stream-wrapper
包简介
A stream wrapper for Flysystem V2 & V3.
README 文档
README
This package provides a stream wrapper for Flysystem V2 & V3.
Flysystem V1
If you're looking for Flysystem 1.x support, check out the twistor/flysystem-stream-wrapper.
Installation
composer require m2mtech/flysystem-stream-wrapper
Usage
use League\Flysystem\Filesystem; use League\Flysystem\Local\LocalFilesystemAdapter; use M2MTech\FlysystemStreamWrapper\FlysystemStreamWrapper; $filesystem = new Filesystem(new LocalFilesystemAdapter('/some/path')); FlysystemStreamWrapper::register('fly', $filesystem); file_put_contents('fly://filename.txt', $content); mkdir('fly://happy_thoughts'); FlysystemStreamWrapper::unregister('fly');
The stream wrapper implements symfony/lock due to Flysystem V2 not supporting locking. By default, file locking using /tmp is used, but you can adjust this through configuration:
FlysystemStreamWrapper::register('fly', $filesystem, [ FlysystemStreamWrapper::LOCK_STORE => 'flock:///tmp', FlysystemStreamWrapper::LOCK_TTL => 300, ]);
Handling Visibility Issues
Some adaptors might throw exceptions when dealing with visibility. If you encounter such issues, configure the stream wrapper to bypass them:
FlysystemStreamWrapper::register('fly', $filesystem, [ FlysystemStreamWrapper::IGNORE_VISIBILITY_ERRORS => true, ]);
Addressing Directory Issues (file_exists / is_dir)
Some adaptors might not return dates for the last modified attribute for directories. In such cases, you can enable emulation to achieve the desired behavior:
FlysystemStreamWrapper::register('fly', $filesystem, [ FlysystemStreamWrapper::EMULATE_DIRECTORY_LAST_MODIFIED => true, ]);
Dealing with is_readable / is_writable
Some filesystem functions depend on the uid and gid of the user executing PHP. Since a reliable cross-platform method to derive these values isn't available, the wrapper attempts to estimate them. If this fails, set them manually:
FlysystemStreamWrapper::register('fly', $filesystem, [ FlysystemStreamWrapper::UID => 1000, FlysystemStreamWrapper::GID => 1000, ]);
Alternatively, access the parameters for PortableVisibilityConverter directly:
FlysystemStreamWrapper::register('fly', $filesystem, [ FlysystemStreamWrapper::VISIBILITY_FILE_PUBLIC => 0644, FlysystemStreamWrapper::VISIBILITY_FILE_PRIVATE => 0600, FlysystemStreamWrapper::VISIBILITY_DIRECTORY_PUBLIC => 0755, FlysystemStreamWrapper::VISIBILITY_DIRECTORY_PRIVATE => 0700, FlysystemStreamWrapper::VISIBILITY_DEFAULT_FOR_DIRECTORIES => Visibility::PRIVATE, ]);
Testing
This package was developed using PHP 7.4 and has been tested for compatibility with PHP versions 7.2 through 8.3.
To test:
- With PHP installed:
composer test
- Inside a Docker environment for PHP 7.4:
docker compose run php74 composer test
Note: PHPUnit v10, used from PHP 8.1 onwards, requires a different config file:
docker compose run php81 composer test10
Changelog
For information on recent changes, refer to the CHANGELOG.
Contributing
For contribution guidelines, see CONTRIBUTING.
Security Vulnerabilities
If you discover any security vulnerabilities, please follow our security policy for reporting.
Credits
- This package was inspired by twistor/flysystem-stream-wrapper. Many thanks to Chris Leppanen.
- All Contributors
License
Licensed under the MIT License. See the License File for more details.
m2mtech/flysystem-stream-wrapper 适用场景与选型建议
m2mtech/flysystem-stream-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 258.39k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2021 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「streamwrapper」 「stream-wrapper」 「Flysystem」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 m2mtech/flysystem-stream-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 m2mtech/flysystem-stream-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 m2mtech/flysystem-stream-wrapper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Interceptors for PHP's native phar:// stream handling
Git Stream Wrapper for PHP
Small library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
Uniform Resource Locator module for UserFrosting
Backblaze B2 Cloud Storage for Laravel 5. Original by Paul Olthof (@hpolthof) continued by @bringyourownideas
Virtual Filesystem Storage Adapter for Laravel
统计信息
- 总下载量: 258.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 34
- 依赖项目数: 4
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2021-11-01