Skip to content

Commit fa96ffc

Browse files
committed
feature: refactor all
php>=8.2 laravel>=11 webman>=1.6.8
1 parent a07e0b8 commit fa96ffc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1054
-1359
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ vendor
33
.idea
44
.vscode
55
composer.lock
6-
/phpunit.xml
76
.phpunit.cache
7+
8+
# for tests,由于 webman 1.6.9 之后 BASE_PATH 不好调整,因此只能被放到项目级别
9+
/config
10+
/storage

README.md

+9-26
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,10 @@ Laravel [illuminate/filesystem](https://packagist.org/packages/illuminate/filesy
1010

1111
## 安装
1212

13-
> 由于 laravel 9 升级了 league/flysystem 到 3.x,详见[Laravel9升级说明](http://laravel.p2hp.com/cndocs/9.x/upgrade#flysystem-3)
14-
,低于 larval 9 的版本需要使用 league/flysystem 1.x 的版本
15-
,<del>因此安装该依赖需要手动安装 `illuminate/filesystem``league/flysystem`</del>
16-
,目前正常能根据 php 版本自动安装响应版本的 `league/flysystem` 无需手动
17-
18-
1. 安装 `webman-tech/laravel-filesystem`
19-
2013
```bash
2114
composer require webman-tech/laravel-filesystem
2215
```
2316

24-
2. 安装 `league/flysystem`
25-
26-
根据 `illuminate/filesystem` 安装后的版本(通过 `composer info illuminate/filesystem` 查看)
27-
28-
```bash
29-
# illuminate/filesystem < 9.0
30-
composer require league/flysystem:~1.1
31-
# illuminate/filesystem >= 9.0
32-
composer require league/flysystem
33-
```
34-
3517
## 使用
3618

3719
所有 API 同 laravel,以下仅对有些特殊的操作做说明
@@ -58,7 +40,8 @@ php webman storage:link
5840
5941
### Request 文件上传
6042

61-
原 Laravel 下通过 `$request()->file()` 之后的快捷文件操作,需要使用 [`webman-tech/polyfill`](https://github.com/webman-tech/polyfill) 来支持
43+
原 Laravel 下通过 `$request()->file()` 之后的快捷文件操作,需要使用 [
44+
`webman-tech/polyfill`](https://github.com/webman-tech/polyfill) 来支持
6245

6346
安装
6447

@@ -92,15 +75,15 @@ class UserAvatarController
9275

9376
### 自定义文件系统
9477

95-
通过在 `filesystems.php` 配置文件的 `disks` 中的 `driver` 直接使用驱动扩展类的 class 名即可(驱动扩展实现 `WebmanTech\LaravelFilesystem\Extend\ExtendInterface`
78+
通过在 `filesystems.php` 配置文件的 `disks` 中的 `driver` 直接使用驱动扩展类的 class 名即可(驱动扩展实现
79+
`WebmanTech\LaravelFilesystem\Extend\ExtendInterface`
9680

9781
目前提供以下非 Laravel 官方库支持的文件系统,可自行参考替换相应的实现
9882

9983
排名不分先后,不做具体推荐
10084

101-
| 厂商 | 扩展包 | 支持 Laravel>=9 | 安装使用 |
102-
|-------------|----------------------------------------------------------------------------------|---------------|----------------------------------------|
103-
| Aliyun OSS | [iidestiny/flysystem-oss](https://github.com/iiDestiny/laravel-filesystem-oss) || [文档](./docs/extends/oss-iidestiny.md) |
104-
| QiNiu | [overtrue/flysystem-qiniu](https://github.com/overtrue/laravel-filesystem-qiniu) || [文档](./docs/extends/qiniu-overtrue.md) |
105-
| Tencent COS | [overtrue/flysystem-cos](https://github.com/overtrue/laravel-filesystem-cos) || [文档](./docs/extends/cos-overtrue.md) |
106-
| Aliyun OSS | [alphasnow/aliyun-oss-laravel](https://github.com/alphasnow/aliyun-oss-laravel) || [文档](./docs/extends/oss-alphasnow.md) |
85+
| 厂商 | 扩展包 | 安装使用 |
86+
|-------------|----------------------------------------------------------------------------------|----------------------------------------|
87+
| QiNiu | [overtrue/flysystem-qiniu](https://github.com/overtrue/laravel-filesystem-qiniu) | [文档](./docs/extends/qiniu-overtrue.md) |
88+
| Tencent COS | [overtrue/flysystem-cos](https://github.com/overtrue/laravel-filesystem-cos) | [文档](./docs/extends/cos-overtrue.md) |
89+
| Aliyun OSS | [alphasnow/aliyun-oss-laravel](https://github.com/alphasnow/aliyun-oss-laravel) | [文档](./docs/extends/oss-alphasnow.md) |

composer.json

+28-17
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@
44
"license": "MIT",
55
"description": "Webman plugin webman-tech/laravel-filesystem",
66
"require": {
7-
"php": ">=7.4",
8-
"illuminate/filesystem": ">=8.0",
9-
"league/flysystem": "^1.1|^3.0"
7+
"php": ">=8.2",
8+
"illuminate/config": "^11.0",
9+
"illuminate/filesystem": "^11.0",
10+
"league/flysystem": "^3.0"
1011
},
1112
"require-dev": {
12-
"alphasnow/aliyun-oss-laravel": "^3.0|^4.0",
13-
"iidestiny/flysystem-oss": "^2.1|^4.0",
14-
"illuminate/http": ">=8.0",
15-
"overtrue/flysystem-cos": "^2|^3|^4|^5",
16-
"overtrue/flysystem-qiniu": "^1|^3",
17-
"phpunit/phpunit": "^8|^9",
18-
"symfony/filesystem": ">=5.0",
19-
"symfony/mime": ">=5.0",
20-
"webman/console": "^1.2",
21-
"webman-tech/polyfill": "^1.0|^2.0",
22-
"workerman/webman-framework": "^1.4"
13+
"alphasnow/aliyun-oss-laravel": "^4.9",
14+
"illuminate/http": "^11.37",
15+
"overtrue/flysystem-cos": "^5.1",
16+
"overtrue/flysystem-qiniu": "^3.2",
17+
"pestphp/pest": "^3.7",
18+
"symfony/http-foundation": "^7.2",
19+
"symfony/mime": "^7.2",
20+
"workerman/webman-framework": "^1.6"
2321
},
22+
"_comments": [
23+
"symfony/mime for File::guessExtension",
24+
"league/flysystem for LocalDriver",
25+
"symfony/http-foundation for FilesystAdapter::response",
26+
"illuminate/http for FilesystAdapter::putFile",
27+
"overtrue/flysystem-cos for cos driver",
28+
"alphasnow/aliyun-oss-laravel for oss driver",
29+
"iidestiny/flysystem-oss for oss driver",
30+
"overtrue/flysystem-qiniu for qiniu driver"
31+
],
2432
"autoload": {
2533
"psr-4": {
2634
"WebmanTech\\LaravelFilesystem\\": "src"
@@ -31,13 +39,16 @@
3139
},
3240
"autoload-dev": {
3341
"psr-4": {
34-
"WebmanTech\\LaravelFilesystem\\Tests\\": "tests"
42+
"Tests\\": "tests"
3543
}
3644
},
3745
"config": {
38-
"sort-packages": true
46+
"sort-packages": true,
47+
"allow-plugins": {
48+
"pestphp/pest-plugin": true
49+
}
3950
},
4051
"scripts": {
41-
"test": "phpunit --testdox --no-interaction"
52+
"test": "pest"
4253
}
4354
}

docs/extends/cos-overtrue.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# 安装依赖
22

33
```bash
4-
# illuminate/filesystem < 9.0
5-
composer require overtrue/flysystem-cos:~3
6-
# illuminate/filesystem >= 9.0
7-
composer require oovertrue/flysystem-cos
4+
composer require overtrue/flysystem-cos
85
```
96

107
# 配置

docs/extends/oss-alphasnow.md

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# 安装依赖
22

33
```bash
4-
# illuminate/filesystem < 9.0
5-
composer require alphasnow/aliyun-oss-laravel:~3.0
6-
# illuminate/filesystem >= 9.0
74
composer require alphasnow/aliyun-oss-laravel
85
```
96

docs/extends/oss-iidestiny.md

-41
This file was deleted.

docs/extends/qiniu-overtrue.md

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# 安装依赖
22

33
```bash
4-
# illuminate/filesystem < 9.0
5-
composer require overtrue/flysystem-qiniu:~1
6-
# illuminate/filesystem >= 9.0
74
composer require overtrue/flysystem-qiniu
85
```
96

phpunit.xml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
4+
bootstrap="tests/bootstrap.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="Test Suite">
9+
<directory suffix="Test.php">./tests</directory>
10+
</testsuite>
11+
</testsuites>
12+
<source>
13+
<include>
14+
<directory suffix=".php">./src</directory>
15+
</include>
16+
</source>
17+
</phpunit>

phpunit.xml.dist

-27
This file was deleted.

src/Extend/CosOvertrueExtend.php

+11-7
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22

33
namespace WebmanTech\LaravelFilesystem\Extend;
44

5-
use WebmanTech\LaravelFilesystem\VersionHelper;
5+
use Illuminate\Filesystem\FilesystemAdapter;
6+
use League\Flysystem\Filesystem;
7+
use Overtrue\Flysystem\Cos\CosAdapter;
68

9+
/**
10+
* @link https://github.com/overtrue/laravel-filesystem-cos/blob/master/src/CosStorageServiceProvider.php
11+
*/
712
class CosOvertrueExtend implements ExtendInterface
813
{
914
/**
1015
* @inheritDoc
1116
*/
12-
public static function createExtend($config)
17+
public static function createExtend(array $config): FilesystemAdapter
1318
{
14-
if (!VersionHelper::isGteFlysystem3()) {
15-
return FlysystemV1\CosOvertrueExtend::createFilesystem($config);
16-
}
17-
return FlysystemV3\CosOvertrueExtend::createFilesystemAdapter($config);
19+
$adapter = new CosAdapter($config);
20+
21+
return new FilesystemAdapter(new Filesystem($adapter), $adapter);
1822
}
19-
}
23+
}

src/Extend/ExtendInterface.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
namespace WebmanTech\LaravelFilesystem\Extend;
44

55
use Illuminate\Filesystem\FilesystemAdapter;
6-
use League\Flysystem\Filesystem;
76

87
interface ExtendInterface
98
{
109
/**
1110
* @param array $config
12-
* @return Filesystem|FilesystemAdapter
11+
* @return FilesystemAdapter
1312
*/
14-
public static function createExtend($config);
13+
public static function createExtend(array $config): FilesystemAdapter;
1514
}

src/Extend/FlysystemV1/CosOvertrueExtend.php

-30
This file was deleted.

src/Extend/FlysystemV1/ExtendInterface.php

-14
This file was deleted.

src/Extend/FlysystemV1/OssAlphaSnowExtend.php

-43
This file was deleted.

0 commit comments

Comments
 (0)