Skip to content

7.0 升级 #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.phar
*.zip
build/artifacts
phpunit.xml
phpunit.functional.xml
.DS_Store
.swp
.build
composer.lock
vendor
src/package.xml
35 changes: 35 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
filter:
excluded_paths: [tests/*]
checks:
php:
code_rating: true
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true
tools:
external_code_coverage:
timeout: 600
runs: 3
php_analyzer: true
php_code_coverage: false
php_code_sniffer:
config:
standard: PSR2
filter:
paths: ['src']
php_loc:
enabled: true
excluded_dirs: [vendor, tests]
php_cpd:
enabled: true
excluded_dirs: [vendor, tests]
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# using docker container
sudo: false

language: php
php:
- 5.2
- 5.3
- 5.4
- 5.5
- 5.6
before_script:
- export QINIU_ACCESS_KEY="Vhiv6a22kVN_zhtetbPNeG9sY3JUL1HG597EmBwQ"
- export QINIU_SECRET_KEY="b5b5vNg5nnkwkPfW5ayicPE_pj6hqgKMQEaWQ6JD"
- export QINIU_ACCESS_KEY="QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm"
- export QINIU_SECRET_KEY="Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz"
- export QINIU_BUCKET_NAME="phpsdk"
- export QINIU_KEY_NAME="file_name"
- export QINIU_KEY_NAME="php-logo.png"
- export QINIU_TEST_ENV="travis"
- composer install --prefer-source
script:
- cd tests; phpunit .
- ./vendor/bin/phpcs --standard=PSR2 src
- ./vendor/bin/phpcs --standard=PSR2 tests
- ./vendor/bin/phpunit tests/Qiniu/Tests/
115 changes: 12 additions & 103 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,103 +1,12 @@
## CHANGE LOG

### v6.1.9

2014-4-8 issues [#75](https://github.com/qiniu/php-sdk/pull/75)

- [#69] 增加User Agent以方便日志查询。
- [#70] 增加Reqid信息以方便错误追溯。
- [#71] Qiniu_RS_Stat返回411问题。

### v6.1.8

2014-4-6 issues [#68](https://github.com/qiniu/php-sdk/pull/68)

- [#66]上传策略[支持mimeLimit字段](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-mime-limit),用于限定上传文件的mimeType。
- [#67] 新增接口的调用范例

### v6.1.7

2014-2-19 issues [#64](https://github.com/qiniu/php-sdk/pull/64)

- 修复 PutExtra.Params 无效的问题

### v6.1.6

2014-2-17 issues [#62](https://github.com/qiniu/php-sdk/pull/62)

- 上传策略[支持transform/fopTimeout字段](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-transform),用于支持对上传内容做一次同步的数据处理,并将结果作为最终资源保存


### v6.1.5

2014-2-13 issues [#59](https://github.com/qiniu/php-sdk/pull/59)

- 修复 PutExtra.MimeType 无效的问题


### v6.1.4

2013-10-25 issues [#52](https://github.com/qiniu/php-sdk/pull/52)

- PutPolicy: 增加 saveKey、persistentOps/persistentNotifyUrl、fsizeLimit 等支持


### v6.1.3

2013-10-09 issues [#50](https://github.com/qiniu/php-sdk/pull/50)

- 断点续上传使用mkfile
- 修订文档
- 消除测试用例并发问题


### v6.1.2

2013-09-24 issue [#40](https://github.com/qiniu/php-sdk/pull/40)

- 解决与某些 PHP 框架不兼容问题(主要是全局变量的定义)
- 改善 `json_decode` 的错误提示(有可能 `json_last_error_msg` 函数不存在)


### v6.1.1

2013-07-04 issue [#24](https://github.com/qiniu/php-sdk/pull/24)

- 支持断点续上传(`Qiniu_RS_Rput`, `Qiniu_RS_RputFile`)


### v6.1.0

2013-07-04 issue [#22](https://github.com/qiniu/php-sdk/pull/22)

- hotfix: 修复上传的时候 key 中不能出现 '/' 的错误


### v6.0.2

2013-07-04 issue [#20](https://github.com/qiniu/php-sdk/pull/20)

- 增加 rsf, batch 支持
- 初步补充文档


### v6.0.1

2013-07-03 issue [#10](https://github.com/qiniu/php-sdk/pull/10)

- new Qiniu_RS_GetPolicy($expires = 0);
- new Qiniu_RS_PutPolicy($scope, $expires = 0);


### v6.0.0

2013-07-02 issue [#9](https://github.com/qiniu/php-sdk/pull/9)

- 遵循 [sdkspec v6.0.2](https://github.com/qiniu/sdkspec/tree/v6.0.2)
- `Qiniu_Put/PutFile` 调整为基于 up.qiniu.com 的协议,extra *PutExtra 参数可以为 nil
- `Qiniu_Put/PutFile` 支持支持 key = null (UNDEFINED_KEY),这样服务端将自动生成 key 并返回
- `Qiniu_Put/PutFile` 支持自定义的 "x:" 参数(io.PutExtra.Params)、支持 Crc 检查
- 待增加:rsf, batch, resumable io 的支持
- bugfix: 修复 crc32 为负数的错误
- 增加 `Qiniu_RS_Put/PutFile` 辅助函数,用于服务端上传

#Changelog

## 7.0.0 (2015-02-03)

### 增加
* 简化上传接口
* 自动选择断点续上传还是直传
* 重构代码,接口和内部结构更清晰
* 改变mime
* 代码覆盖度报告
* policy改为array, 便于灵活增加,并加入过期字段检查
* 文件列表支持目录形式
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 贡献代码指南

我们非常欢迎大家来贡献代码,我们会向贡献者致以最诚挚的敬意。

一般可以通过在Github上提交[Pull Request](https://github.com/qiniu/php-sdk)来贡献代码。

## Pull Request要求

- **[PSR-2 编码风格标准](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** 。要通过项目中的code sniffer检查。

- **代码格式** 提交前 请按 ./vendor/bin/phpcbf --standard=PSR2 进行格式化。

- **必须添加测试!** - 如果没有测试(单元测试、集成测试都可以),那么提交的补丁是不会通过的。

- **记得更新文档** - 保证`README.md`以及其他相关文档及时更新,和代码的变更保持一致性。

- **考虑我们的发布周期** - 我们的版本号会服从[SemVer v2.0.0](http://semver.org/),我们绝对不会随意变更对外的API。

- **创建feature分支** - 最好不要从你的master分支提交 pull request。

- **一个feature提交一个pull请求** - 如果你的代码变更了多个操作,那就提交多个pull请求吧。

- **清晰的commit历史** - 保证你的pull请求的每次commit操作都是有意义的。如果你开发中需要执行多次的即时commit操作,那么请把它们放到一起再提交pull请求。

## 运行测试

``` bash
./vendor/bin/phpunit tests/Qiniu/Tests/

```
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2014 Qiniu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

9 changes: 0 additions & 9 deletions Makefile

This file was deleted.

74 changes: 51 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,69 @@
# Qiniu Resource Storage SDK for PHP
[![@qiniu on weibo](http://img.shields.io/badge/weibo-%40qiniutek-blue.svg)](http://weibo.com/qiniutek)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
[![Build Status](https://travis-ci.org/qiniu/php-sdk.svg)](https://travis-ci.org/qiniu/php-sdk)
[![Latest Stable Version](https://img.shields.io/packagist/v/qiniu/php-sdk.svg)](https://packagist.org/packages/qiniu/php-sdk)
[![Total Downloads](https://img.shields.io/packagist/dt/qiniu/php-sdk.svg)](https://packagist.org/packages/qiniu/php-sdk)
[![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)
[![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)
## 安装

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

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

| Qiniu SDK版本 | PHP 版本 |
|:--------------------:|:---------------------------:|
| 7.x | cURL extension, 5.3 - 5.6 |
| 6.x | cURL extension, 5.2 - 5.6 |

## 下载
## 使用方法

### 从 release 版本下载
### 上传
```php
use Qiniu\Storage\UploadManager;
use Qiniu\Auth;
...
$upManager = new UploadManager();
$auth = new Auth($accessKey, $secretKey);
$token = $auth->uploadToken($bucketName);
list($ret, $error) = $upManager->put($token, 'formput', 'hello world');
...
```

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

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

### 从 git 库下载
## 常见问题

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

## 代码贡献

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

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

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

## 贡献代码
## 联系我们

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

## 代码许可

## 许可证

Copyright (c) 2012-2014 qiniu.com

基于 MIT 协议发布:

* [www.opensource.org/licenses/MIT](http://www.opensource.org/licenses/MIT)
The MIT License (MIT).详情见 [License文件](https://github.com/qiniu/php-sdk/blob/master/LICENSE).
20 changes: 16 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@
"name": "qiniu/php-sdk",
"type": "library",
"description": "Qiniu Resource (Cloud) Storage SDK for PHP",
"keywords": ["qiniu","storage","CDN","sdk"],
"homepage": "http://www.qiniu.com/",
"keywords": ["qiniu", "storage", "sdk", "cloud"],
"homepage": "http://developer.qiniu.com/",
"license": "MIT",
"authors": [
{
"name": "Qiniu",
"email": "sdk@qiniu.com",
"homepage": "http://www.qiniu.com"
}
],
"require": {
"php": ">=5.2.4"
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"autoload": {
"files": ["qiniu/rs_utils.php"]
"psr-4": {"Qiniu\\": "src/Qiniu"},
"files": ["src/Qiniu/functions.php"]
}
}
11 changes: 0 additions & 11 deletions demo/fetch.php

This file was deleted.

Loading