Skip to content

Commit ce8574d

Browse files
committed
[新增功能](master): init
0 parents commit ce8574d

Some content is hidden

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

58 files changed

+3290
-0
lines changed

.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

.gitignore

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

.php_cs

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

.phpstorm.meta.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace PHPSTORM_META {
4+
5+
// Reflect
6+
override(\Psr\Container\ContainerInterface::get(0), map('@'));
7+
override(\Hyperf\Utils\Context::get(0), map('@'));
8+
override(\make(0), map('@'));
9+
override(\di(0), map('@'));
10+
11+
}

LICENSE

Whitespace-only changes.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# framework
2+
framework

composer.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "mochat/framework",
3+
"type": "library",
4+
"keywords": [
5+
"php",
6+
"hyperf",
7+
"mochat",
8+
"framework"
9+
],
10+
"description": "framework of mochat",
11+
"autoload": {
12+
"psr-4": {
13+
"MoChat\\Framework\\": "src/"
14+
},
15+
"files": [
16+
"src/Functions.php"
17+
]
18+
},
19+
"autoload-dev": {
20+
"psr-4": {
21+
"HyperfTest\\": "tests"
22+
}
23+
},
24+
"require": {
25+
"php": ">=7.2",
26+
"ext-swoole": ">=4.5"
27+
},
28+
"require-dev": {
29+
"96qbhy/hyperf-auth": "^2.2",
30+
"friendsofphp/php-cs-fixer": "^2.14",
31+
"hyperf/framework": "^2.0",
32+
"hyperf/testing": "2.0.*",
33+
"overtrue/wechat": "~4.0",
34+
"phpstan/phpstan": "^0.12",
35+
"swoole/ide-helper": "dev-master",
36+
"hyperf/guzzle": "^2.0"
37+
},
38+
"config": {
39+
"sort-packages": true
40+
},
41+
"scripts": {
42+
"test": "co-phpunit -c phpunit.xml --colors=always",
43+
"analyse": "phpstan analyse --memory-limit 1024M -l 0 ./src",
44+
"cs-fix": "php-cs-fixer fix $1"
45+
},
46+
"extra": {
47+
"hyperf": {
48+
"config": "MoChat\\Framework\\ConfigProvider"
49+
}
50+
}
51+
}

publish/dependencies.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of MoChat.
6+
* @link https://mo.chat
7+
* @document https://mochat.wiki
8+
* @contact group@mo.chat
9+
* @license https://github.com/mochat-cloud/mochat/blob/master/LICENSE
10+
*/
11+
use Hyperf\Contract\StdoutLoggerInterface;
12+
use MoChat\Framework\Log\StdoutLoggerFactory;
13+
14+
$dependencies = [];
15+
16+
$appEnv = env('APP_ENV', 'production');
17+
if ($appEnv !== 'dev') {
18+
$dependencies[StdoutLoggerInterface::class] = StdoutLoggerFactory::class;
19+
}
20+
21+
return $dependencies + [
22+
];

publish/framework.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of MoChat.
6+
* @link https://mo.chat
7+
* @document https://mochat.wiki
8+
* @contact group@mo.chat
9+
* @license https://github.com/mochat-cloud/mochat/blob/master/LICENSE
10+
*/
11+
return [
12+
// MoChat\Framework\Middleware\JwtAuthMiddleware jwt路由验证白名单
13+
'auth_white_routes' => [
14+
'/user/auth', '/weWork/callback',
15+
],
16+
17+
// MoChat\Framework\Middleware\ResponseMiddleware 原生响应格式的路由
18+
'response_raw_routes' => [
19+
'/weWork/callback',
20+
],
21+
22+
'wework' => [
23+
'config' => [
24+
// 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
25+
'response_type' => 'array',
26+
27+
'log' => [
28+
'level' => 'debug',
29+
'file' => BASE_PATH . '/runtime/logs/wechat.log',
30+
],
31+
],
32+
'default' => [
33+
'provider' => 'app',
34+
],
35+
'providers' => [
36+
'app' => [
37+
'name' => \MoChat\Framework\Provider\WeWork\AppProvider::class,
38+
'service' => App\Model\Corp::class, // 需要实现 MoChat\Framework\Contract\WeWork\AppConfigurable 接口
39+
],
40+
'user' => [
41+
'name' => \MoChat\Framework\Provider\WeWork\UserProvider::class,
42+
'service' => App\Model\Corp::class, // 需要实现 MoChat\Framework\Contract\WeWork\UserConfigurable 接口
43+
],
44+
'externalContact' => [
45+
'name' => \MoChat\Framework\Provider\WeWork\ExternalContactProvider::class,
46+
'service' => App\Model\Corp::class, // 需要实现 MoChat\Framework\Contract\WeWork\ExternalContactConfigurable 接口
47+
],
48+
'agent' => [
49+
'name' => \MoChat\Framework\Provider\WeWork\AgentProvider::class,
50+
'service' => App\Model\Corp::class, // 需要实现 MoChat\Framework\Contract\WeWork\AgentConfigurable 接口
51+
],
52+
],
53+
],
54+
];

src/Action/AbstractAction.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of MoChat.
6+
* @link https://mo.chat
7+
* @document https://mochat.wiki
8+
* @contact group@mo.chat
9+
* @license https://github.com/mochat-cloud/mochat/blob/master/LICENSE
10+
*/
11+
namespace MoChat\Framework\Action;
12+
13+
use Hyperf\Di\Annotation\Inject;
14+
use Hyperf\HttpServer\Contract\RequestInterface;
15+
use Hyperf\HttpServer\Contract\ResponseInterface;
16+
use Psr\Container\ContainerInterface;
17+
18+
abstract class AbstractAction
19+
{
20+
/**
21+
* @Inject
22+
* @var ContainerInterface
23+
*/
24+
protected $container;
25+
26+
/**
27+
* @Inject
28+
* @var RequestInterface
29+
*/
30+
protected $request;
31+
32+
/**
33+
* @Inject
34+
* @var ResponseInterface
35+
*/
36+
protected $response;
37+
}

0 commit comments

Comments
 (0)