Skip to content

Commit a6f4bdf

Browse files
committed
Merge pull request #106 from longbai/7.0
7.0 升级
2 parents 35b583a + 4225ed2 commit a6f4bdf

Some content is hidden

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

67 files changed

+2024
-3708
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.phar
2+
*.zip
3+
build/artifacts
4+
phpunit.xml
5+
phpunit.functional.xml
6+
.DS_Store
7+
.swp
8+
.build
9+
composer.lock
10+
vendor
11+
src/package.xml

.scrutinizer.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
filter:
2+
excluded_paths: [tests/*]
3+
checks:
4+
php:
5+
code_rating: true
6+
remove_extra_empty_lines: true
7+
remove_php_closing_tag: true
8+
remove_trailing_whitespace: true
9+
fix_use_statements:
10+
remove_unused: true
11+
preserve_multiple: false
12+
preserve_blanklines: true
13+
order_alphabetically: true
14+
fix_php_opening_tag: true
15+
fix_linefeed: true
16+
fix_line_ending: true
17+
fix_identation_4spaces: true
18+
fix_doc_comments: true
19+
tools:
20+
external_code_coverage:
21+
timeout: 600
22+
runs: 3
23+
php_analyzer: true
24+
php_code_coverage: false
25+
php_code_sniffer:
26+
config:
27+
standard: PSR2
28+
filter:
29+
paths: ['src']
30+
php_loc:
31+
enabled: true
32+
excluded_dirs: [vendor, tests]
33+
php_cpd:
34+
enabled: true
35+
excluded_dirs: [vendor, tests]

.travis.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
# using docker container
2+
sudo: false
3+
14
language: php
25
php:
3-
- 5.2
46
- 5.3
57
- 5.4
68
- 5.5
79
- 5.6
810
before_script:
9-
- export QINIU_ACCESS_KEY="Vhiv6a22kVN_zhtetbPNeG9sY3JUL1HG597EmBwQ"
10-
- export QINIU_SECRET_KEY="b5b5vNg5nnkwkPfW5ayicPE_pj6hqgKMQEaWQ6JD"
11+
- export QINIU_ACCESS_KEY="QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm"
12+
- export QINIU_SECRET_KEY="Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz"
1113
- export QINIU_BUCKET_NAME="phpsdk"
12-
- export QINIU_KEY_NAME="file_name"
14+
- export QINIU_KEY_NAME="php-logo.png"
1315
- export QINIU_TEST_ENV="travis"
16+
- composer install --prefer-source
1417
script:
15-
- cd tests; phpunit .
18+
- ./vendor/bin/phpcs --standard=PSR2 src
19+
- ./vendor/bin/phpcs --standard=PSR2 tests
20+
- ./vendor/bin/phpunit tests/Qiniu/Tests/

CHANGELOG.md

Lines changed: 12 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,12 @@
1-
## CHANGE LOG
2-
3-
### v6.1.9
4-
5-
2014-4-8 issues [#75](https://github.com/qiniu/php-sdk/pull/75)
6-
7-
- [#69] 增加User Agent以方便日志查询。
8-
- [#70] 增加Reqid信息以方便错误追溯。
9-
- [#71] Qiniu_RS_Stat返回411问题。
10-
11-
### v6.1.8
12-
13-
2014-4-6 issues [#68](https://github.com/qiniu/php-sdk/pull/68)
14-
15-
- [#66]上传策略[支持mimeLimit字段](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-mime-limit),用于限定上传文件的mimeType。
16-
- [#67] 新增接口的调用范例
17-
18-
### v6.1.7
19-
20-
2014-2-19 issues [#64](https://github.com/qiniu/php-sdk/pull/64)
21-
22-
- 修复 PutExtra.Params 无效的问题
23-
24-
### v6.1.6
25-
26-
2014-2-17 issues [#62](https://github.com/qiniu/php-sdk/pull/62)
27-
28-
- 上传策略[支持transform/fopTimeout字段](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-transform),用于支持对上传内容做一次同步的数据处理,并将结果作为最终资源保存
29-
30-
31-
### v6.1.5
32-
33-
2014-2-13 issues [#59](https://github.com/qiniu/php-sdk/pull/59)
34-
35-
- 修复 PutExtra.MimeType 无效的问题
36-
37-
38-
### v6.1.4
39-
40-
2013-10-25 issues [#52](https://github.com/qiniu/php-sdk/pull/52)
41-
42-
- PutPolicy: 增加 saveKey、persistentOps/persistentNotifyUrl、fsizeLimit 等支持
43-
44-
45-
### v6.1.3
46-
47-
2013-10-09 issues [#50](https://github.com/qiniu/php-sdk/pull/50)
48-
49-
- 断点续上传使用mkfile
50-
- 修订文档
51-
- 消除测试用例并发问题
52-
53-
54-
### v6.1.2
55-
56-
2013-09-24 issue [#40](https://github.com/qiniu/php-sdk/pull/40)
57-
58-
- 解决与某些 PHP 框架不兼容问题(主要是全局变量的定义)
59-
- 改善 `json_decode` 的错误提示(有可能 `json_last_error_msg` 函数不存在)
60-
61-
62-
### v6.1.1
63-
64-
2013-07-04 issue [#24](https://github.com/qiniu/php-sdk/pull/24)
65-
66-
- 支持断点续上传(`Qiniu_RS_Rput`, `Qiniu_RS_RputFile`)
67-
68-
69-
### v6.1.0
70-
71-
2013-07-04 issue [#22](https://github.com/qiniu/php-sdk/pull/22)
72-
73-
- hotfix: 修复上传的时候 key 中不能出现 '/' 的错误
74-
75-
76-
### v6.0.2
77-
78-
2013-07-04 issue [#20](https://github.com/qiniu/php-sdk/pull/20)
79-
80-
- 增加 rsf, batch 支持
81-
- 初步补充文档
82-
83-
84-
### v6.0.1
85-
86-
2013-07-03 issue [#10](https://github.com/qiniu/php-sdk/pull/10)
87-
88-
- new Qiniu_RS_GetPolicy($expires = 0);
89-
- new Qiniu_RS_PutPolicy($scope, $expires = 0);
90-
91-
92-
### v6.0.0
93-
94-
2013-07-02 issue [#9](https://github.com/qiniu/php-sdk/pull/9)
95-
96-
- 遵循 [sdkspec v6.0.2](https://github.com/qiniu/sdkspec/tree/v6.0.2)
97-
- `Qiniu_Put/PutFile` 调整为基于 up.qiniu.com 的协议,extra *PutExtra 参数可以为 nil
98-
- `Qiniu_Put/PutFile` 支持支持 key = null (UNDEFINED_KEY),这样服务端将自动生成 key 并返回
99-
- `Qiniu_Put/PutFile` 支持自定义的 "x:" 参数(io.PutExtra.Params)、支持 Crc 检查
100-
- 待增加:rsf, batch, resumable io 的支持
101-
- bugfix: 修复 crc32 为负数的错误
102-
- 增加 `Qiniu_RS_Put/PutFile` 辅助函数,用于服务端上传
103-
1+
#Changelog
2+
3+
## 7.0.0 (2015-02-03)
4+
5+
### 增加
6+
* 简化上传接口
7+
* 自动选择断点续上传还是直传
8+
* 重构代码,接口和内部结构更清晰
9+
* 改变mime
10+
* 代码覆盖度报告
11+
* policy改为array, 便于灵活增加,并加入过期字段检查
12+
* 文件列表支持目录形式

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# 贡献代码指南
2+
3+
我们非常欢迎大家来贡献代码,我们会向贡献者致以最诚挚的敬意。
4+
5+
一般可以通过在Github上提交[Pull Request](https://github.com/qiniu/php-sdk)来贡献代码。
6+
7+
## Pull Request要求
8+
9+
- **[PSR-2 编码风格标准](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** 。要通过项目中的code sniffer检查。
10+
11+
- **代码格式** 提交前 请按 ./vendor/bin/phpcbf --standard=PSR2 进行格式化。
12+
13+
- **必须添加测试!** - 如果没有测试(单元测试、集成测试都可以),那么提交的补丁是不会通过的。
14+
15+
- **记得更新文档** - 保证`README.md`以及其他相关文档及时更新,和代码的变更保持一致性。
16+
17+
- **考虑我们的发布周期** - 我们的版本号会服从[SemVer v2.0.0](http://semver.org/),我们绝对不会随意变更对外的API。
18+
19+
- **创建feature分支** - 最好不要从你的master分支提交 pull request。
20+
21+
- **一个feature提交一个pull请求** - 如果你的代码变更了多个操作,那就提交多个pull请求吧。
22+
23+
- **清晰的commit历史** - 保证你的pull请求的每次commit操作都是有意义的。如果你开发中需要执行多次的即时commit操作,那么请把它们放到一起再提交pull请求。
24+
25+
## 运行测试
26+
27+
``` bash
28+
./vendor/bin/phpunit tests/Qiniu/Tests/
29+
30+
```

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Qiniu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

Makefile

Lines changed: 0 additions & 9 deletions
This file was deleted.

README.md

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,69 @@
11
# Qiniu Resource Storage SDK for PHP
2+
[![@qiniu on weibo](http://img.shields.io/badge/weibo-%40qiniutek-blue.svg)](http://weibo.com/qiniutek)
3+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
4+
[![Build Status](https://travis-ci.org/qiniu/php-sdk.svg)](https://travis-ci.org/qiniu/php-sdk)
5+
[![Latest Stable Version](https://img.shields.io/packagist/v/qiniu/php-sdk.svg)](https://packagist.org/packages/qiniu/php-sdk)
6+
[![Total Downloads](https://img.shields.io/packagist/dt/qiniu/php-sdk.svg)](https://packagist.org/packages/qiniu/php-sdk)
7+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/qiniu/php-sdk/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/qiniu/php-sdk/?branch=master)
8+
[![Code Coverage](https://scrutinizer-ci.com/g/qiniu/php-sdk/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/qiniu/php-sdk/?branch=master)
9+
## 安装
210

3-
[![Build Status](https://api.travis-ci.org/qiniu/php-sdk.png?branch=master)](https://travis-ci.org/qiniu/php-sdk)
11+
1. 通过composer
12+
```bash
13+
$ composer require qiniu/php-sdk
14+
```
15+
2. 直接下载安装,SDK 没有依赖其他第三方库,但需要使用composer的autoload
416

5-
[![Qiniu Logo](http://qiniu-brand.qiniudn.com/5/logo-white-195x105.png)](http://www.qiniu.com/)
17+
## 运行环境
618

19+
| Qiniu SDK版本 | PHP 版本 |
20+
|:--------------------:|:---------------------------:|
21+
| 7.x | cURL extension, 5.3 - 5.6 |
22+
| 6.x | cURL extension, 5.2 - 5.6 |
723

8-
## 下载
24+
## 使用方法
925

10-
### 从 release 版本下载
26+
### 上传
27+
```php
28+
use Qiniu\Storage\UploadManager;
29+
use Qiniu\Auth;
30+
...
31+
$upManager = new UploadManager();
32+
$auth = new Auth($accessKey, $secretKey);
33+
$token = $auth->uploadToken($bucketName);
34+
list($ret, $error) = $upManager->put($token, 'formput', 'hello world');
35+
...
36+
```
1137

12-
下载地址:https://github.com/qiniu/php-sdk/releases
38+
## 测试
1339

14-
这是我们建议的方式,release 版本有版本号,有 [CHANGELOG](https://github.com/qiniu/php-sdk/blob/develop/CHANGELOG.md),使用规格也会比较稳定。
40+
``` bash
41+
$ ./vendor/bin/phpunit tests/Qiniu/Tests/
42+
```
1543

16-
### 从 git 库下载
44+
## 常见问题
1745

18-
你可以直接用 git clone 下载源代码来使用。但是请注意非 master 分支的代码在规格上可能承受变更,应谨慎使用。
46+
- $error保留了请求响应的信息,失败情况下ret 为none, 将$error可以打印出来,提交给我们。
47+
- API 的使用 demo 可以参考 [单元测试](https://github.com/qiniu/php-sdk/blob/master/tests)
1948

49+
## 代码贡献
2050

21-
## 使用
51+
详情参考[代码提交指南](https://github.com/qiniu/php-sdk/blob/master/CONTRIBUTING.md)
2252

23-
参考文档:[七牛云存储 PHP SDK 使用指南](https://github.com/qiniu/php-sdk/tree/develop/docs)
53+
## 贡献记录
2454

55+
- [所有贡献者](https://github.com/qiniu/php-sdk/contributors)
2556

26-
## 贡献代码
57+
## 联系我们
2758

28-
1. Fork
29-
2. 创建您的特性分支 (`git checkout -b my-new-feature`)
30-
3. 提交您的改动 (`git commit -am 'Added some feature'`)
31-
4. 将您的修改记录提交到远程 `git` 仓库 (`git push origin my-new-feature`)
32-
5. 然后到 github 网站的该 `git` 远程仓库的 `my-new-feature` 分支下发起 Pull Request
59+
- 如果需要帮助,请提交工单(在portal右侧点击咨询和建议提交工单,或者直接向 support@qiniu.com 发送邮件)
60+
- 如果有什么问题,可以到问答社区提问,[问答社区](http://qiniu.segmentfault.com/)
61+
- 更详细的文档,见[官方文档站](http://developer.qiniu.com/)
62+
- 如果发现了bug, 欢迎提交 [issue](https://github.com/qiniu/php-sdk/issues)
63+
- 如果有功能需求,欢迎提交 [issue](https://github.com/qiniu/php-sdk/issues)
64+
- 如果要提交代码,欢迎提交 pull request
65+
- 欢迎关注我们的[微信](http://www.qiniu.com/#weixin) [微博](http://weibo.com/qiniutek),及时获取动态信息。
3366

67+
## 代码许可
3468

35-
## 许可证
36-
37-
Copyright (c) 2012-2014 qiniu.com
38-
39-
基于 MIT 协议发布:
40-
41-
* [www.opensource.org/licenses/MIT](http://www.opensource.org/licenses/MIT)
69+
The MIT License (MIT).详情见 [License文件](https://github.com/qiniu/php-sdk/blob/master/LICENSE).

composer.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22
"name": "qiniu/php-sdk",
33
"type": "library",
44
"description": "Qiniu Resource (Cloud) Storage SDK for PHP",
5-
"keywords": ["qiniu","storage","CDN","sdk"],
6-
"homepage": "http://www.qiniu.com/",
5+
"keywords": ["qiniu", "storage", "sdk", "cloud"],
6+
"homepage": "http://developer.qiniu.com/",
77
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Qiniu",
11+
"email": "sdk@qiniu.com",
12+
"homepage": "http://www.qiniu.com"
13+
}
14+
],
815
"require": {
9-
"php": ">=5.2.4"
16+
"php": ">=5.3.3"
17+
},
18+
"require-dev": {
19+
"phpunit/phpunit": "~4.0",
20+
"squizlabs/php_codesniffer": "~2.0"
1021
},
1122
"autoload": {
12-
"files": ["qiniu/rs_utils.php"]
23+
"psr-4": {"Qiniu\\": "src/Qiniu"},
24+
"files": ["src/Qiniu/functions.php"]
1325
}
1426
}

demo/fetch.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)