doesntcarewho / modifyed_flysystem
Flysystem 是 Laravel 的 Flysystem 桥接器
Requires
- php: ^7.2.5 || ^8.0
- graham-campbell/manager: ^4.5
- illuminate/contracts: ^6.0 || ^7.0 || ^8.0
- illuminate/support: ^6.0 || ^7.0 || ^8.0
- league/flysystem: ^1.1.1
Requires (Dev)
- alcaeus/mongo-php-adapter: ^1.1
- graham-campbell/analyzer: ^3.0
- graham-campbell/testbench: ^5.4
- league/flysystem-aws-s3-v3: ^1.0
- league/flysystem-azure-blob-storage: ^0.1.6
- league/flysystem-cached-adapter: ^1.0
- league/flysystem-eventable-filesystem: ^1.0
- league/flysystem-gridfs: ^1.0
- league/flysystem-sftp: ^1.0
- league/flysystem-webdav: ^1.0
- league/flysystem-ziparchive: ^1.0
- mockery/mockery: ^1.3.1
- phpunit/phpunit: ^8.5.8 || ^9.3.7
- spatie/flysystem-dropbox: ^1.0
- superbalist/flysystem-google-storage: ^7.2
Suggests
- alcaeus/mongo-php-adapter: GridFS adapter support.
- league/flysystem-aws-s3-v3: AwsS3 adapter support.
- league/flysystem-azure-blob-storage: Azure adapter support.
- league/flysystem-cached-adapter: Adapter caching support.
- league/flysystem-eventable-filesystem: Eventable filesystem support.
- league/flysystem-gridfs: GridFS adapter support.
- league/flysystem-replicate-adapter: Replicate adapter support.
- league/flysystem-sftp: Sftp adapter support.
- league/flysystem-webdav: WebDav adapter support.
- league/flysystem-ziparchive: ZipArchive adapter support.
- spatie/flysystem-dropbox: Dropbox adapter support.
- superbalist/flysystem-google-storage: GoogleCloudStorage adapter support.
- 7.1.x-dev
- v7.1.1
- v7.1.0
- v7.0.1
- v7.0.0
- 6.3.x-dev
- v6.3.1
- v6.3.0
- v6.2.0
- v6.1.0
- v6.0.0
- 5.3.x-dev
- v5.3.0
- v5.2.0
- v5.1.0
- v5.0.0
- 4.1.x-dev
- v4.1.0
- v4.0.0
- 3.7.x-dev
- v3.7.0
- v3.6.0
- v3.5.0
- v3.4.0
- v3.3.1
- v3.3.0
- v3.2.0
- v3.1.0
- v3.0.0
- v2.1.1
- v2.1.0
- v2.0.0
- v1.0.0
- v1.0.0-RC1
- v0.7.0-alpha
- v0.6.2-alpha
- v0.6.1-alpha
- v0.6.0-alpha
- v0.5.2-alpha
- v0.5.1-alpha
- v0.5.0-alpha
- v0.4.0-alpha
- v0.3.0-alpha
- v0.2.0-alpha
- v0.1.0-alpha
This package is not auto-updated.
Last update: 2024-09-27 15:06:37 UTC
README
Laravel Flysystem 由 GrahamCampbell 创建并维护,是一个Flysystem 桥接器,用于 Laravel。它使用我的 Laravel Manager 包。您可以查看变更日志、版本发布、安全策略、许可、行为准则以及贡献指南。
安装
Laravel Flysystem 需要 PHP 7.2-8.0。这个特定版本支持 Laravel 6-8。
要获取最新版本,只需使用 Composer 引入项目
$ composer require "graham-campbell/flysystem:^7.1"
还有一些额外的依赖项需要安装以支持某些功能
- AwsS3 适配器需要
league/flysystem-aws-s3-v3
(^1.0
)。 - Azure 适配器需要
league/flysystem-azure-blob-storage
(^0.1.6
)。 - Dropbox 适配器需要
spatie/flysystem-dropbox
(^1.0
)。 - GoogleCloudStorage 适配器需要
superbalist/flysystem-google-storage
(^7.2
)。 - GridFS 适配器需要
league/flysystem-gridfs
(^1.0
) 和alcaeus/mongo-php-adapter
(^1.1
)。 - Sftp 适配器需要
league/flysystem-sftp
(^1.0
)。 - WebDav 适配器需要
league/flysystem-webdav
(^1.0
)。 - ZipAdapter 适配器需要
league/flysystem-ziparchive
(^1.0
)。 - 适配器缓存支持需要
league/flysystem-cached-adapter
(^1.0
)。 - 事件文件系统支持需要
league/flysystem-eventable-filesystem
(^1.0
)。
安装完成后,如果您没有使用自动包发现,那么您需要在您的 config/app.php
中注册 GrahamCampbell\Flysystem\FlysystemServiceProvider
服务提供者。
您还可以选择性地给我们的外观别名
'Flysystem' => GrahamCampbell\Flysystem\Facades\Flysystem::class,
配置
Laravel Flysystem 需要连接配置。
要开始,您需要发布所有供应商资产
$ php artisan vendor:publish
这将在您的应用程序中创建一个 config/flysystem.php
文件,您可以修改该文件来设置您的配置。同时,请确保检查此包在版本之间的原始配置文件的变化。
有三个配置选项
默认连接名称
此选项(《default》)是您指定以下哪个连接作为您所有工作的默认连接的地方。当然,您可以使用管理器类同时使用多个连接。此设置的默认值是《local》。
Flysystem 连接
此选项(《connections》)是设置应用程序中每个连接的地方。配置每个支持的驱动程序的示例包括在配置文件中,你应该已经“发布”。当然,每个驱动程序可以有多个连接。
Flysystem缓存
此选项(《cache》)是设置应用程序中每个缓存配置的地方。目前有两个驱动程序:illuminate和adapter。配置示例已包含在内。当然,每个驱动程序可以有多个连接,如图所示。
用法
FlysystemManager
这是最感兴趣的类。它绑定到ioc容器中的'flysystem'
,可以通过Facades\Flysystem
外观类访问。此类通过扩展AbstractManager
实现了ManagerInterface
。接口和抽象类都是我Laravel Manager包的一部分,所以你可能想要去那个仓库查看如何使用管理器类的文档。请注意,返回的连接类将始终是实现了\League\Flysystem\FilesystemInterface
的类的实例,默认情况下是\League\Flysystem\Filesystem
。
Facades\Flysystem
此外观将动态地将静态方法调用传递给ioc容器中的'flysystem'
对象,默认情况下是FlysystemManager
类。
FlysystemServiceProvider
此类不包含任何有趣的公共方法。应该将此类添加到config/app.php
中的提供者数组。此类将设置ioc绑定。
实际示例
在这里,你可以看到一个示例,说明这个包是多么简单易用。默认情况下,默认适配器是local
,它会立即开始工作。
use GrahamCampbell\Flysystem\Facades\Flysystem; // you can alias this in config/app.php if you like Flysystem::put('hi.txt', 'foo'); // we're done here - how easy was that, it just works! Flysystem::read('hi.txt'); // this will return foo
Flysystem管理器将表现得像一个\League\Flysystem\Filesystem
类。如果你想调用特定的连接,可以使用connection
方法。
use GrahamCampbell\Flysystem\Facades\Flysystem; // note the foo connection does not ship with this package, it's hypothetical Flysystem::connection('foo')->put('test.txt', 'bar'); // now we can read that file Flysystem::connection('foo')->read('test.txt'); // this will return bar
考虑到这一点,请注意:
use GrahamCampbell\Flysystem\Facades\Flysystem; // writing this: Flysystem::connection('local')->read('test.txt'); // is identical to writing this: Flysystem::read('test.txt'); // and is also identical to writing this: Flysystem::connection()->read('test.txt'); // this is because the local connection is configured to be the default Flysystem::getDefaultConnection(); // this will return local // we can change the default connection Flysystem::setDefaultConnection('foo'); // the default is now foo
如果你像我一样喜欢使用依赖注入而不是外观,那么你可以轻松地这样注入管理器
use GrahamCampbell\Flysystem\FlysystemManager; use Illuminate\Support\Facades\App; // you probably have this aliased already class Foo { protected $flysystem; public function __construct(FlysystemManager $flysystem) { $this->flysystem = $flysystem; } public function bar() { $this->flysystem->read('test.txt'); } } App::make('Foo')->bar();
有关如何使用我们幕后调用的\League\Flysystem\Filesystem
类的更多信息,请查看https://flysystem.thephpleague.com/docs/usage/filesystem-api/的文档,以及管理器类在https://github.com/GrahamCampbell/Laravel-Manager#usage。
更多信息
此包中还有其他未在此记录的类。这是因为它们不是用于公共用途的,而是由本包内部使用的。
安全
如果你在此包中发现安全漏洞,请发送电子邮件到Graham Campbell的graham@alt-three.com。所有安全漏洞都将得到及时处理。您可以在此处查看我们的完整安全策略。
许可
Laravel Flysystem受MIT许可(MIT)许可。
企业版
作为Tidelift订阅的一部分提供
graham-campbell/flysystem
的维护者以及成千上万的包维护者正在与Tidelift合作,为构建应用程序时使用的开源依赖项提供商业支持和维护。节省时间,降低风险,并提高代码健康,同时支付您使用的确切依赖项的维护者。了解更多。