Skip to content

Commit c0c2228

Browse files
committed
init
0 parents  commit c0c2228

21 files changed

Lines changed: 1178 additions & 0 deletions

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/tests export-ignore
2+
/.github export-ignore

.github/workflows/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
push:
3+
# Sequence of patterns matched against refs/tags
4+
tags:
5+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
7+
name: Release
8+
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
- name: Create Release
17+
id: create_release
18+
uses: actions/create-release@v1
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
with:
22+
tag_name: ${{ github.ref }}
23+
release_name: Release ${{ github.ref }}
24+
draft: false
25+
prerelease: false

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/vendor/
2+
composer.lock
3+
*.cache
4+
*.log
5+
.idea/
6+
.DS_Store

.php_cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of Hyperf.
5+
6+
@link https://www.hyperf.io
7+
@document https://hyperf.wiki
8+
@contact group@hyperf.io
9+
@license https://github.com/hyperf/hyperf/blob/master/LICENSE
10+
EOF;
11+
12+
return PhpCsFixer\Config::create()
13+
->setRiskyAllowed(true)
14+
->setRules([
15+
'@PSR2' => true,
16+
'@Symfony' => true,
17+
'@DoctrineAnnotation' => true,
18+
'@PhpCsFixer' => true,
19+
'header_comment' => [
20+
'commentType' => 'PHPDoc',
21+
'header' => $header,
22+
'separate' => 'none',
23+
'location' => 'after_declare_strict',
24+
],
25+
'array_syntax' => [
26+
'syntax' => 'short'
27+
],
28+
'list_syntax' => [
29+
'syntax' => 'short'
30+
],
31+
'concat_space' => [
32+
'spacing' => 'one'
33+
],
34+
'blank_line_before_statement' => [
35+
'statements' => [
36+
'declare',
37+
],
38+
],
39+
'general_phpdoc_annotation_remove' => [
40+
'annotations' => [
41+
'author'
42+
],
43+
],
44+
'ordered_imports' => [
45+
'imports_order' => [
46+
'class', 'function', 'const',
47+
],
48+
'sort_algorithm' => 'alpha',
49+
],
50+
'single_line_comment_style' => [
51+
'comment_types' => [
52+
],
53+
],
54+
'yoda_style' => [
55+
'always_move_variable' => false,
56+
'equal' => false,
57+
'identical' => false,
58+
],
59+
'phpdoc_align' => [
60+
'align' => 'left',
61+
],
62+
'multiline_whitespace_before_semicolons' => [
63+
'strategy' => 'no_multi_line',
64+
],
65+
'constant_case' => [
66+
'case' => 'lower',
67+
],
68+
'class_attributes_separation' => true,
69+
'combine_consecutive_unsets' => true,
70+
'declare_strict_types' => true,
71+
'linebreak_after_opening_tag' => true,
72+
'lowercase_static_reference' => true,
73+
'no_useless_else' => true,
74+
'no_unused_imports' => true,
75+
'not_operator_with_successor_space' => true,
76+
'not_operator_with_space' => false,
77+
'ordered_class_elements' => true,
78+
'php_unit_strict' => false,
79+
'phpdoc_separation' => false,
80+
'single_quote' => true,
81+
'standardize_not_equals' => true,
82+
'multiline_comment_opening_closing' => true,
83+
])
84+
->setFinder(
85+
PhpCsFixer\Finder::create()
86+
->exclude('bin')
87+
->exclude('public')
88+
->exclude('runtime')
89+
->exclude('vendor')
90+
->in(__DIR__)
91+
)
92+
->setUsingCache(false);

.travis.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
language: php
2+
3+
sudo: required
4+
5+
matrix:
6+
include:
7+
- php: 7.2
8+
env: SW_VERSION="4.5.3RC1"
9+
- php: 7.3
10+
env: SW_VERSION="4.5.3RC1"
11+
- php: 7.4
12+
env: SW_VERSION="4.5.3RC1"
13+
14+
allow_failures:
15+
- php: master
16+
17+
services:
18+
- docker
19+
20+
before_install:
21+
- export PHP_MAJOR="$(`phpenv which php` -r 'echo phpversion();' | cut -d '.' -f 1)"
22+
- export PHP_MINOR="$(`phpenv which php` -r 'echo phpversion();' | cut -d '.' -f 2)"
23+
- echo $PHP_MAJOR
24+
- echo $PHP_MINOR
25+
26+
install:
27+
- cd $TRAVIS_BUILD_DIR
28+
- bash .travis/swoole.install.sh
29+
- phpenv config-rm xdebug.ini || echo "xdebug not available"
30+
- phpenv config-add .travis/ci.ini
31+
32+
before_script:
33+
- cd $TRAVIS_BUILD_DIR
34+
- composer config -g process-timeout 900 && composer update
35+
36+
script:
37+
- composer analyse
38+
- composer test

.travis/ci.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[opcache]
2+
opcache.enable_cli=1
3+
4+
[swoole]
5+
extension = "swoole.so"

.travis/swoole.install.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
wget https://github.com/swoole/swoole-src/archive/v"${SW_VERSION}".tar.gz -O swoole.tar.gz
3+
mkdir -p swoole
4+
tar -xf swoole.tar.gz -C swoole --strip-components=1
5+
rm swoole.tar.gz
6+
cd swoole || exit
7+
phpize
8+
./configure --enable-openssl --enable-mysqlnd --enable-http2
9+
make -j "$(nproc)"
10+
make install

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Taylor Otwell
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.

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Hyperf Cookie 组件
2+
3+
该组件移植自 Laravel([illuminate/cookie](https://github.com/illuminate/cookie )),功能与 Laravel 保持一致。
4+
5+
> 注意,该组件与 Hyperf 官方组件差异很大,使用时切勿混淆。
6+
7+
## 安装
8+
9+
```shell script
10+
composer require hyperf-ext/cookie
11+
```
12+
13+
## 发布配置
14+
15+
```shell script
16+
php bin/hyperf.php vendor:publish hyperf-ext/cookie
17+
```
18+
19+
> 配置文件位于 `config/autoload/ext-cookie.php`
20+
21+
## 设置
22+
23+
在配置文件 `config/autoload/middlewares.php` 中添加全局中间件 `HyperfExt\Cookie\Middleware\QueuedCookieMiddleware`
24+
25+
如需对 Cookie 加密,额外添加全局中间件 `HyperfExt\Cookie\Middleware\EncryptCookieMiddleware`
26+
27+
> 注意,使用 Cookie 加密中间件需要依赖 [`hyperf-ext/encryption`](https://github.com/hyperf-ext/encryption) 组件。
28+
> 并且需求将该中间件放置在首位,以保证将请求中的加密 Cookie 解密。
29+
30+
## 使用
31+
32+
在任何需要设置 Cookie 的地方注入 `HyperfExt\Cookie\Contract\CookieJarInterface`,该接口绑定的是 `HyperfExt\Cookie\CookieJar` 的代理类实例对象。
33+
34+
该对象存储在当前请求的协程上下文中,在当前协程周期内访问到的都是同一个对象。
35+

composer.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "hyperf-ext/cookie",
3+
"type": "library",
4+
"license": "MIT",
5+
"keywords": [
6+
"php",
7+
"hyperf",
8+
"cookie"
9+
],
10+
"description": "The unofficial Hyperf Queued Cookie package.",
11+
"authors": [
12+
{
13+
"name": "Eric Zhu",
14+
"email": "eric@zhu.email"
15+
},
16+
{
17+
"name": "Taylor Otwell",
18+
"email": "taylor@laravel.com"
19+
}
20+
],
21+
"autoload": {
22+
"psr-4": {
23+
"HyperfExt\\Cookie\\": "src/"
24+
}
25+
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"HyperfTest\\": "tests"
29+
}
30+
},
31+
"require": {
32+
"php": ">=7.2",
33+
"ext-swoole": ">=4.5",
34+
"hyperf/di": "^2.0",
35+
"hyperf/framework": "^2.0"
36+
},
37+
"require-dev": {
38+
"friendsofphp/php-cs-fixer": "^2.14",
39+
"hyperf/testing": "^2.0",
40+
"phpstan/phpstan": "^0.12",
41+
"swoole/ide-helper": "dev-master"
42+
},
43+
"suggest": {
44+
"hyperf-ext/encryption": "For encrypt cookies"
45+
},
46+
"config": {
47+
"sort-packages": true
48+
},
49+
"scripts": {
50+
"test": "co-phpunit -c phpunit.xml --colors=always",
51+
"analyse": "phpstan analyse --memory-limit 1024M -l 0 ./src",
52+
"cs-fix": "php-cs-fixer fix $1"
53+
},
54+
"extra": {
55+
"hyperf": {
56+
"config": "HyperfExt\\Cookie\\ConfigProvider"
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)