Skip to content

Commit a4f55fd

Browse files
committed
init
0 parents  commit a4f55fd

43 files changed

Lines changed: 1095 additions & 0 deletions

Some content is hidden

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

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APP_DEBUG = true[APP]DEFAULT_TIMEZONE = Asia/Shanghai[DATABASE]TYPE = mysqlHOSTNAME = 127.0.0.1DATABASE = testUSERNAME = usernamePASSWORD = passwordHOSTPORT = 3306CHARSET = utf8DEBUG = true[LANG]default_lang = zh-cn

.gitignore

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

.php_cs

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

.travis.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
sudo: false
2+
3+
language: php
4+
5+
branches:
6+
only:
7+
- stable
8+
9+
cache:
10+
directories:
11+
- $HOME/.composer/cache
12+
13+
before_install:
14+
- composer self-update
15+
16+
install:
17+
- composer install --no-dev --no-interaction --ignore-platform-reqs
18+
- zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip .
19+
- composer require --update-no-dev --no-interaction "topthink/think-image:^1.0"
20+
- composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0"
21+
- composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0"
22+
- composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0"
23+
- composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0"
24+
- composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0"
25+
- composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0"
26+
- composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0"
27+
- composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0"
28+
- zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip .
29+
30+
script:
31+
- php think unit
32+
33+
deploy:
34+
provider: releases
35+
api_key:
36+
secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw=
37+
file:
38+
- ThinkPHP_Core.zip
39+
- ThinkPHP_Full.zip
40+
skip_cleanup: true
41+
on:
42+
tags: true

LICENSE.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
3+
版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
4+
All rights reserved。
5+
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
6+
7+
Apache Licence是著名的非盈利开源组织Apache采用的协议。
8+
该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
9+
允许代码修改,再作为开源或商业软件发布。需要满足
10+
的条件:
11+
1. 需要给代码的用户一份Apache Licence ;
12+
2. 如果你修改了代码,需要在被修改的文件中说明;
13+
3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
14+
带有原来代码中的协议,商标,专利声明和其他原来作者规
15+
定需要包含的说明;
16+
4. 如果再发布的产品中包含一个Notice文件,则在Notice文
17+
件中需要带有本协议内容。你可以在Notice中增加自己的
18+
许可,但不可以表现为对Apache Licence构成更改。
19+
具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ThinkPHP Skeleton
2+
===============
3+
4+
> 运行环境要求PHP7.1+。
5+
6+
### 安装
7+
```sh
8+
$ composer i
9+
```
10+
11+
### 启动
12+
```sh
13+
$ composer start
14+
```
15+
16+
### 格式化代码
17+
```sh
18+
$ composer cs-fix path
19+
```
20+
21+
### 代码静态分析
22+
```sh
23+
$ composer analyze
24+
```

app/.htaccess

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deny from all

app/BaseController.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of ThinkPHP.
6+
* @link https://www.thinkphp.cn
7+
* @document https://www.kancloud.cn/manual/thinkphp6_0
8+
* @contact group@thinkphp.cn
9+
* @license https://github.com/top-think/think/blob/6.0/LICENSE.txt
10+
*/
11+
12+
namespace app;
13+
14+
use think\App;
15+
use think\exception\ValidateException;
16+
use think\Validate;
17+
18+
/**
19+
* 控制器基础类.
20+
*/
21+
abstract class BaseController
22+
{
23+
/**
24+
* Request实例.
25+
* @var \think\Request
26+
*/
27+
protected $request;
28+
29+
/**
30+
* 应用实例.
31+
* @var \think\App
32+
*/
33+
protected $app;
34+
35+
/**
36+
* 是否批量验证
37+
* @var bool
38+
*/
39+
protected $batchValidate = false;
40+
41+
/**
42+
* 控制器中间件.
43+
* @var array
44+
*/
45+
protected $middleware = [];
46+
47+
/**
48+
* 构造方法.
49+
* @param App $app 应用对象
50+
*/
51+
public function __construct(App $app)
52+
{
53+
$this->app = $app;
54+
$this->request = $this->app->request;
55+
56+
// 控制器初始化
57+
$this->initialize();
58+
}
59+
60+
// 初始化
61+
protected function initialize()
62+
{
63+
}
64+
65+
/**
66+
* 验证数据.
67+
* @param array $data 数据
68+
* @param array|string $validate 验证器名或者验证规则数组
69+
* @param array $message 提示信息
70+
* @param bool $batch 是否批量验证
71+
* @throws ValidateException
72+
* @return array|string|true
73+
*/
74+
protected function validate(array $data, $validate, array $message = [], bool $batch = false)
75+
{
76+
if (is_array($validate)) {
77+
$v = new Validate();
78+
$v->rule($validate);
79+
} else {
80+
if (strpos($validate, '.')) {
81+
// 支持场景
82+
[$validate, $scene] = explode('.', $validate);
83+
}
84+
$class = strpos($validate, '\\') !== false ? $validate : $this->app->parseClass('validate', $validate);
85+
$v = new $class();
86+
if (! empty($scene)) {
87+
$v->scene($scene);
88+
}
89+
}
90+
91+
$v->message($message);
92+
93+
// 是否批量验证
94+
if ($batch || $this->batchValidate) {
95+
$v->batch(true);
96+
}
97+
98+
return $v->failException(true)->check($data);
99+
}
100+
}

app/ExceptionHandle.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of ThinkPHP.
6+
* @link https://www.thinkphp.cn
7+
* @document https://www.kancloud.cn/manual/thinkphp6_0
8+
* @contact group@thinkphp.cn
9+
* @license https://github.com/top-think/think/blob/6.0/LICENSE.txt
10+
*/
11+
12+
namespace app;
13+
14+
use think\db\exception\DataNotFoundException;
15+
use think\db\exception\ModelNotFoundException;
16+
use think\exception\Handle;
17+
use think\exception\HttpException;
18+
use think\exception\HttpResponseException;
19+
use think\exception\ValidateException;
20+
use think\Response;
21+
use Throwable;
22+
23+
/**
24+
* 应用异常处理类.
25+
*/
26+
class ExceptionHandle extends Handle
27+
{
28+
/**
29+
* 不需要记录信息(日志)的异常类列表.
30+
* @var array
31+
*/
32+
protected $ignoreReport = [
33+
HttpException::class,
34+
HttpResponseException::class,
35+
ModelNotFoundException::class,
36+
DataNotFoundException::class,
37+
ValidateException::class,
38+
];
39+
40+
/**
41+
* 记录异常信息(包括日志或者其它方式记录).
42+
*
43+
* @param Throwable $exception
44+
*/
45+
public function report(Throwable $exception): void
46+
{
47+
// 使用内置的方式记录异常日志
48+
parent::report($exception);
49+
}
50+
51+
/**
52+
* Render an exception into an HTTP response.
53+
*
54+
* @param \think\Request $request
55+
* @param Throwable $e
56+
* @return Response
57+
*/
58+
public function render($request, Throwable $e): Response
59+
{
60+
// 添加自定义异常处理机制
61+
62+
// 其他错误交给系统处理
63+
return parent::render($request, $e);
64+
}
65+
}

app/Request.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of ThinkPHP.
6+
* @link https://www.thinkphp.cn
7+
* @document https://www.kancloud.cn/manual/thinkphp6_0
8+
* @contact group@thinkphp.cn
9+
* @license https://github.com/top-think/think/blob/6.0/LICENSE.txt
10+
*/
11+
12+
namespace app;
13+
14+
// 应用请求对象类
15+
class Request extends \think\Request
16+
{
17+
}

0 commit comments

Comments
 (0)