commit
1642c22b03
62 changed files with 1637 additions and 0 deletions
@ -0,0 +1,12 @@ |
|||||
|
*.log |
||||
|
.env |
||||
|
composer.phar |
||||
|
composer.lock |
||||
|
.DS_Store |
||||
|
Thumbs.db |
||||
|
/.idea |
||||
|
/.vscode |
||||
|
/vendor |
||||
|
/.settings |
||||
|
/.buildpath |
||||
|
/.project |
||||
@ -0,0 +1,42 @@ |
|||||
|
sudo: false |
||||
|
|
||||
|
language: php |
||||
|
|
||||
|
branches: |
||||
|
only: |
||||
|
- stable |
||||
|
|
||||
|
cache: |
||||
|
directories: |
||||
|
- $HOME/.composer/cache |
||||
|
|
||||
|
before_install: |
||||
|
- composer self-update |
||||
|
|
||||
|
install: |
||||
|
- composer install --no-dev --no-interaction --ignore-platform-reqs |
||||
|
- zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip . |
||||
|
- composer require --update-no-dev --no-interaction "topthink/think-image:^1.0" |
||||
|
- composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0" |
||||
|
- composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0" |
||||
|
- composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0" |
||||
|
- composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0" |
||||
|
- composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0" |
||||
|
- composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0" |
||||
|
- composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0" |
||||
|
- composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0" |
||||
|
- zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip . |
||||
|
|
||||
|
script: |
||||
|
- php think unit |
||||
|
|
||||
|
deploy: |
||||
|
provider: releases |
||||
|
api_key: |
||||
|
secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw= |
||||
|
file: |
||||
|
- ThinkPHP_Core.zip |
||||
|
- ThinkPHP_Full.zip |
||||
|
skip_cleanup: true |
||||
|
on: |
||||
|
tags: true |
||||
@ -0,0 +1,32 @@ |
|||||
|
|
||||
|
ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 |
||||
|
版权所有Copyright © 2006-2023 by ThinkPHP (http://thinkphp.cn) |
||||
|
All rights reserved。 |
||||
|
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 |
||||
|
|
||||
|
Apache Licence是著名的非盈利开源组织Apache采用的协议。 |
||||
|
该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, |
||||
|
允许代码修改,再作为开源或商业软件发布。需要满足 |
||||
|
的条件: |
||||
|
1. 需要给代码的用户一份Apache Licence ; |
||||
|
2. 如果你修改了代码,需要在被修改的文件中说明; |
||||
|
3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 |
||||
|
带有原来代码中的协议,商标,专利声明和其他原来作者规 |
||||
|
定需要包含的说明; |
||||
|
4. 如果再发布的产品中包含一个Notice文件,则在Notice文 |
||||
|
件中需要带有本协议内容。你可以在Notice中增加自己的 |
||||
|
许可,但不可以表现为对Apache Licence构成更改。 |
||||
|
具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
|
||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
||||
|
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
||||
|
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
||||
|
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
||||
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
|
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
|
POSSIBILITY OF SUCH DAMAGE. |
||||
@ -0,0 +1,79 @@ |
|||||
|
 |
||||
|
|
||||
|
ThinkPHP 8.0 |
||||
|
=============== |
||||
|
|
||||
|
## 特性 |
||||
|
|
||||
|
* 基于PHP`8.0+`重构 |
||||
|
* 升级`PSR`依赖 |
||||
|
* 依赖`think-orm`3.0版本 |
||||
|
* `6.0`/`6.1`无缝升级 |
||||
|
|
||||
|
|
||||
|
> ThinkPHP8.0的运行环境要求PHP8.0.0+ |
||||
|
|
||||
|
现在开始,你可以使用官方提供的[ThinkChat](https://chat.topthink.com/),让你在学习ThinkPHP的旅途中享受私人AI助理服务! |
||||
|
|
||||
|
 |
||||
|
|
||||
|
## 文档 |
||||
|
|
||||
|
[完全开发手册](https://doc.thinkphp.cn) |
||||
|
|
||||
|
## 服务 |
||||
|
|
||||
|
ThinkPHP生态服务由[顶想云](https://www.topthink.com)(TOPThink Cloud)提供,为生态提供专业的开发者服务和价值之选。 |
||||
|
|
||||
|
## 赞助 |
||||
|
全新的[赞助计划](https://www.thinkphp.cn/sponsor)可以让你通过我们的网站、手册、欢迎页及GIT仓库获得巨大曝光,同时提升企业的品牌声誉,也更好保障ThinkPHP的可持续发展。 |
||||
|
|
||||
|
[](http://github.crmeb.net/u/TPSY) |
||||
|
|
||||
|
[](https://www.thinkphp.cn/sponsor) |
||||
|
|
||||
|
[](https://www.thinkphp.cn/sponsor) |
||||
|
|
||||
|
## 安装 |
||||
|
|
||||
|
~~~ |
||||
|
composer create-project topthink/think tp |
||||
|
~~~ |
||||
|
|
||||
|
启动服务 |
||||
|
|
||||
|
~~~ |
||||
|
cd tp |
||||
|
php think run |
||||
|
~~~ |
||||
|
|
||||
|
然后就可以在浏览器中访问 |
||||
|
|
||||
|
~~~ |
||||
|
http://localhost:8000 |
||||
|
~~~ |
||||
|
|
||||
|
如果需要更新框架使用 |
||||
|
~~~ |
||||
|
composer update topthink/framework |
||||
|
~~~ |
||||
|
|
||||
|
## 命名规范 |
||||
|
|
||||
|
`ThinkPHP`遵循PSR-2命名规范和PSR-4自动加载规范。 |
||||
|
|
||||
|
## 参与开发 |
||||
|
|
||||
|
直接提交PR或者Issue即可 |
||||
|
|
||||
|
## 版权信息 |
||||
|
|
||||
|
ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 |
||||
|
|
||||
|
本项目包含的第三方源码和二进制文件之版权信息另行标注。 |
||||
|
|
||||
|
版权所有Copyright © 2006-2023 by ThinkPHP (http://thinkphp.cn) All rights reserved。 |
||||
|
|
||||
|
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 |
||||
|
|
||||
|
更多细节参阅 [LICENSE.txt](LICENSE.txt) |
||||
@ -0,0 +1 @@ |
|||||
|
deny from all |
||||
@ -0,0 +1,10 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<title>Title</title> |
||||
|
</head> |
||||
|
<body> |
||||
|
[自定义404] |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,22 @@ |
|||||
|
<?php |
||||
|
declare (strict_types = 1); |
||||
|
|
||||
|
namespace app; |
||||
|
|
||||
|
use think\Service; |
||||
|
|
||||
|
/** |
||||
|
* 应用服务类 |
||||
|
*/ |
||||
|
class AppService extends Service |
||||
|
{ |
||||
|
public function register() |
||||
|
{ |
||||
|
// 服务注册 |
||||
|
} |
||||
|
|
||||
|
public function boot() |
||||
|
{ |
||||
|
// 服务启动 |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,94 @@ |
|||||
|
<?php |
||||
|
declare (strict_types = 1); |
||||
|
|
||||
|
namespace app; |
||||
|
|
||||
|
use think\App; |
||||
|
use think\exception\ValidateException; |
||||
|
use think\Validate; |
||||
|
|
||||
|
/** |
||||
|
* 控制器基础类 |
||||
|
*/ |
||||
|
abstract class BaseController |
||||
|
{ |
||||
|
/** |
||||
|
* Request实例 |
||||
|
* @var \think\Request |
||||
|
*/ |
||||
|
protected $request; |
||||
|
|
||||
|
/** |
||||
|
* 应用实例 |
||||
|
* @var \think\App |
||||
|
*/ |
||||
|
protected $app; |
||||
|
|
||||
|
/** |
||||
|
* 是否批量验证 |
||||
|
* @var bool |
||||
|
*/ |
||||
|
protected $batchValidate = false; |
||||
|
|
||||
|
/** |
||||
|
* 控制器中间件 |
||||
|
* @var array |
||||
|
*/ |
||||
|
protected $middleware = []; |
||||
|
|
||||
|
/** |
||||
|
* 构造方法 |
||||
|
* @access public |
||||
|
* @param App $app 应用对象 |
||||
|
*/ |
||||
|
public function __construct(App $app) |
||||
|
{ |
||||
|
$this->app = $app; |
||||
|
$this->request = $this->app->request; |
||||
|
|
||||
|
// 控制器初始化 |
||||
|
$this->initialize(); |
||||
|
} |
||||
|
|
||||
|
// 初始化 |
||||
|
protected function initialize() |
||||
|
{} |
||||
|
|
||||
|
/** |
||||
|
* 验证数据 |
||||
|
* @access protected |
||||
|
* @param array $data 数据 |
||||
|
* @param string|array $validate 验证器名或者验证规则数组 |
||||
|
* @param array $message 提示信息 |
||||
|
* @param bool $batch 是否批量验证 |
||||
|
* @return array|string|true |
||||
|
* @throws ValidateException |
||||
|
*/ |
||||
|
protected function validate(array $data, string|array $validate, array $message = [], bool $batch = false) |
||||
|
{ |
||||
|
if (is_array($validate)) { |
||||
|
$v = new Validate(); |
||||
|
$v->rule($validate); |
||||
|
} else { |
||||
|
if (strpos($validate, '.')) { |
||||
|
// 支持场景 |
||||
|
[$validate, $scene] = explode('.', $validate); |
||||
|
} |
||||
|
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); |
||||
|
$v = new $class(); |
||||
|
if (!empty($scene)) { |
||||
|
$v->scene($scene); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$v->message($message); |
||||
|
|
||||
|
// 是否批量验证 |
||||
|
if ($batch || $this->batchValidate) { |
||||
|
$v->batch(true); |
||||
|
} |
||||
|
|
||||
|
return $v->failException(true)->check($data); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
<?php |
||||
|
namespace app; |
||||
|
|
||||
|
use think\db\exception\DataNotFoundException; |
||||
|
use think\db\exception\ModelNotFoundException; |
||||
|
use think\exception\Handle; |
||||
|
use think\exception\HttpException; |
||||
|
use think\exception\HttpResponseException; |
||||
|
use think\exception\ValidateException; |
||||
|
use think\Response; |
||||
|
use Throwable; |
||||
|
|
||||
|
/** |
||||
|
* 应用异常处理类 |
||||
|
*/ |
||||
|
class ExceptionHandle extends Handle |
||||
|
{ |
||||
|
/** |
||||
|
* 不需要记录信息(日志)的异常类列表 |
||||
|
* @var array |
||||
|
*/ |
||||
|
protected $ignoreReport = [ |
||||
|
HttpException::class, |
||||
|
HttpResponseException::class, |
||||
|
ModelNotFoundException::class, |
||||
|
DataNotFoundException::class, |
||||
|
ValidateException::class, |
||||
|
]; |
||||
|
|
||||
|
/** |
||||
|
* 记录异常信息(包括日志或者其它方式记录) |
||||
|
* |
||||
|
* @access public |
||||
|
* @param Throwable $exception |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function report(Throwable $exception): void |
||||
|
{ |
||||
|
// 使用内置的方式记录异常日志 |
||||
|
parent::report($exception); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Render an exception into an HTTP response. |
||||
|
* |
||||
|
* @access public |
||||
|
* @param \think\Request $request |
||||
|
* @param Throwable $e |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function render($request, Throwable $e): Response |
||||
|
{ |
||||
|
// 添加自定义异常处理机制 |
||||
|
|
||||
|
// 其他错误交给系统处理 |
||||
|
return parent::render($request, $e); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
<?php |
||||
|
namespace app; |
||||
|
|
||||
|
// 应用请求对象类 |
||||
|
class Request extends \think\Request |
||||
|
{ |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,2 @@ |
|||||
|
<?php |
||||
|
// 这是系统自动生成的公共文件 |
||||
@ -0,0 +1,95 @@ |
|||||
|
<?php |
||||
|
|
||||
|
/** |
||||
|
* Created by 安徽云掌信息技术有限公司.捕梦者团队 |
||||
|
* User: 云掌.邦德 |
||||
|
* Date: 2024.2024/4/23.下午11:19 |
||||
|
* Desc: |
||||
|
*/ |
||||
|
|
||||
|
declare (strict_types=1); |
||||
|
|
||||
|
namespace app\adminapi\controller; |
||||
|
|
||||
|
use app\adminapi\model\Demo as DemoModel; |
||||
|
use think\Request; |
||||
|
|
||||
|
class Demo |
||||
|
{ |
||||
|
/** |
||||
|
* 显示资源列表 |
||||
|
* |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function index() |
||||
|
{ |
||||
|
echo 'index'; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 显示创建资源表单页. |
||||
|
* |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function create(Demo $demoModel) |
||||
|
{ |
||||
|
// |
||||
|
echo $demoModel->list(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 保存新建的资源 |
||||
|
* |
||||
|
* @param \think\Request $request |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function save(Request $request) |
||||
|
{ |
||||
|
// |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 显示指定的资源 |
||||
|
* |
||||
|
* @param int $id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function read($id) |
||||
|
{ |
||||
|
// |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 显示编辑资源表单页. |
||||
|
* |
||||
|
* @param int $id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function edit($id) |
||||
|
{ |
||||
|
// |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 保存更新的资源 |
||||
|
* |
||||
|
* @param \think\Request $request |
||||
|
* @param int $id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function update(Request $request, $id) |
||||
|
{ |
||||
|
// |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除指定资源 |
||||
|
* |
||||
|
* @param int $id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function delete($id) |
||||
|
{ |
||||
|
// |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
<?php |
||||
|
/** |
||||
|
* Created by 安徽云掌信息技术有限公司.捕梦者团队 |
||||
|
* User: 云掌.邦德 |
||||
|
* Date: 2024.2024/4/24.上午1:49 |
||||
|
* Desc: |
||||
|
*/ |
||||
|
|
||||
|
namespace app\adminapi\controller; |
||||
|
|
||||
|
class Error |
||||
|
{ |
||||
|
public function index() |
||||
|
{ |
||||
|
return send_http_status([], 500); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
<?php |
||||
|
declare (strict_types = 1); |
||||
|
|
||||
|
namespace app\adminapi\controller; |
||||
|
|
||||
|
class Index |
||||
|
{ |
||||
|
public function index() |
||||
|
{ |
||||
|
return '您好!这是一个[adminapi]示例应用'; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
<?php |
||||
|
// 这是系统自动生成的event定义文件 |
||||
|
return [ |
||||
|
|
||||
|
]; |
||||
@ -0,0 +1,5 @@ |
|||||
|
<?php |
||||
|
// 这是系统自动生成的middleware定义文件 |
||||
|
return [ |
||||
|
|
||||
|
]; |
||||
@ -0,0 +1,23 @@ |
|||||
|
<?php |
||||
|
/** |
||||
|
* Created by 安徽云掌信息技术有限公司.捕梦者团队 |
||||
|
* User: 云掌.邦德 |
||||
|
* Date: 2024.2024/4/23.下午11:19 |
||||
|
* Desc: |
||||
|
*/ |
||||
|
declare (strict_types=1); |
||||
|
|
||||
|
namespace app\adminapi\model; |
||||
|
|
||||
|
use think\Model; |
||||
|
|
||||
|
/** |
||||
|
* @mixin \think\Model |
||||
|
*/ |
||||
|
class Demo extends Model |
||||
|
{ |
||||
|
public function list() |
||||
|
{ |
||||
|
return 'list'; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
<?php |
||||
|
use app\ExceptionHandle; |
||||
|
use app\Request; |
||||
|
|
||||
|
// 容器Provider定义文件 |
||||
|
return [ |
||||
|
'think\Request' => Request::class, |
||||
|
// 'think\exception\Handle' => ExceptionHandle::class, //原系统 |
||||
|
'think\exception\Handle' => 'app\\exception\\ExceptionHandle', //自定义异常类 |
||||
|
]; |
||||
@ -0,0 +1,2 @@ |
|||||
|
<?php |
||||
|
// 这是系统自动生成的公共文件 |
||||
@ -0,0 +1,12 @@ |
|||||
|
<?php |
||||
|
declare (strict_types = 1); |
||||
|
|
||||
|
namespace app\api\controller; |
||||
|
|
||||
|
class Index |
||||
|
{ |
||||
|
public function index() |
||||
|
{ |
||||
|
return '您好!这是一个[api]示例应用'; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
<?php |
||||
|
|
||||
|
/** |
||||
|
* Created by 安徽云掌信息技术有限公司.捕梦者团队 |
||||
|
* User: 云掌.邦德 |
||||
|
* Date: 2024.2024/4/23.下午11:19 |
||||
|
* Desc: |
||||
|
*/ |
||||
|
|
||||
|
namespace app\api\controller\v1; |
||||
|
|
||||
|
class Demo |
||||
|
{ |
||||
|
|
||||
|
public function test() |
||||
|
{ |
||||
|
return 'test'; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
<?php |
||||
|
// 这是系统自动生成的event定义文件 |
||||
|
return [ |
||||
|
|
||||
|
]; |
||||
@ -0,0 +1,5 @@ |
|||||
|
<?php |
||||
|
// 这是系统自动生成的middleware定义文件 |
||||
|
return [ |
||||
|
|
||||
|
]; |
||||
@ -0,0 +1,10 @@ |
|||||
|
<?php |
||||
|
use app\ExceptionHandle; |
||||
|
use app\Request; |
||||
|
|
||||
|
// 容器Provider定义文件 |
||||
|
return [ |
||||
|
'think\Request' => Request::class, |
||||
|
// 'think\exception\Handle' => ExceptionHandle::class, //原系统 |
||||
|
'think\exception\Handle' => 'app\\exception\\ExceptionHandle', //自定义异常类 |
||||
|
]; |
||||
@ -0,0 +1,275 @@ |
|||||
|
<?php |
||||
|
// 应用公共文件 |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 解析文档注释正则匹配 |
||||
|
* @param $str //完整注释 |
||||
|
* @param string $tag 获取指定的标签数据 |
||||
|
* @return string |
||||
|
*/ |
||||
|
if (!function_exists('get_doc_comment')) { |
||||
|
function get_doc_comment($str, $tag = '') |
||||
|
{ |
||||
|
if (empty($tag)) { |
||||
|
return $str; |
||||
|
} |
||||
|
|
||||
|
$matches = array(); |
||||
|
preg_match("/@" . $tag . "(.*)(\\r\\n|\\r|\\n)/U", $str, $matches); |
||||
|
|
||||
|
if (isset($matches[1])) { |
||||
|
return trim($matches[1]); |
||||
|
} |
||||
|
|
||||
|
return ''; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 自定义全局验证器 判断同站点是否有重复数据 示例:uniqueSite:表名 |
||||
|
* @param $value 验证数据 |
||||
|
* @param $rule 验证规则:表名 |
||||
|
* @param $data 全部数据(数组) |
||||
|
* @param $name 字段名 |
||||
|
* @param $note 字段描述 |
||||
|
* @return bool |
||||
|
*/ |
||||
|
function extra_unique_validate($value, $rule, $data, $name, $note) |
||||
|
{ |
||||
|
$_db = \think\facade\Db::table($rule)->where('site_id', SITE_ID); |
||||
|
//id存在需要判断修改逻辑下排除id本身且不为空的情况下 有没有重复 |
||||
|
$id = !empty($data['id']) ? $data['id'] : ''; |
||||
|
if ($id) { |
||||
|
$_db->where('id', '<>', $id); |
||||
|
$_db->where($name, '<>', ' '); |
||||
|
} |
||||
|
$_data = $_db->where($name, $value)->find(); |
||||
|
if (empty($_data)) { |
||||
|
return true; |
||||
|
} |
||||
|
return $note . '已存在,请重新输入!!!'; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* json统一返回 |
||||
|
* @param type $code 状态编码 0正常 |
||||
|
* @param type $data 返回数据 |
||||
|
* @param type $msg 错误的提示信息 |
||||
|
* @return type |
||||
|
*/ |
||||
|
function send_http_status($data = [], $code = 0, $httpStatus = 200, $msg = '') |
||||
|
{ |
||||
|
$msg = !empty($msg) ? $msg : config('dictionary')[$code]; |
||||
|
//排除成功的状态信息 |
||||
|
if (in_array($code, [201, 203, 205, 207, 209])) { |
||||
|
$code = 0; |
||||
|
} |
||||
|
|
||||
|
$_data = [ |
||||
|
'code' => $code, |
||||
|
'msg' => $msg, |
||||
|
// 'count' => 0, |
||||
|
'data' => $data, |
||||
|
]; |
||||
|
|
||||
|
//更改data2级数据为一级 增加列表页count数据 |
||||
|
// if (isset($data['count'])) { |
||||
|
// $_data['count'] = $data['count']; //前端框架element 1.30版本以前接口模式 |
||||
|
// $_data['data'] = empty($data['data']) ? [] : $data['data']; //前端框架element 1.30版本以前接口模式 |
||||
|
// } |
||||
|
|
||||
|
if ($code != 0 && $code != 200) { |
||||
|
throw new \app\exception\HttpException($httpStatus, $msg, $code); |
||||
|
} |
||||
|
return json($_data, $httpStatus); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 把格式数组,拆分父栏目,与子栏目 |
||||
|
* @param type $arr 一级数组 |
||||
|
* @param type $pid 父id |
||||
|
* @param type $child_name 生成子数组的名称 |
||||
|
* @param type $primary 表的主键值,上一级id |
||||
|
* @return type |
||||
|
*/ |
||||
|
function get_tree(array $arr, $pid = 0, $child_name = 'children', $primary = 'id') |
||||
|
{ |
||||
|
if (empty($arr)) { |
||||
|
return $arr; |
||||
|
} |
||||
|
if (is_array($arr)) { |
||||
|
$child = get_child($arr, $pid); |
||||
|
if (empty($child)) { |
||||
|
return null; |
||||
|
} |
||||
|
foreach ($child as $key => $value) { |
||||
|
$current_child = get_tree($arr, $value[$primary]); |
||||
|
if ($current_child != null) { |
||||
|
$child[$key][$child_name] = $current_child; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return $child; |
||||
|
} |
||||
|
|
||||
|
//根据pid获取子栏目 返回子栏目数组集合 |
||||
|
function get_child($arr, $pid = 0) |
||||
|
{ |
||||
|
if (is_array($arr)) { |
||||
|
$child = array(); |
||||
|
foreach ($arr as $key => $value) { |
||||
|
if ($value['parent_id'] == $pid) { |
||||
|
$child[$key] = $value; |
||||
|
} |
||||
|
} |
||||
|
return array_values($child); |
||||
|
} |
||||
|
return $arr; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 云掌图片服务器裁剪函数 |
||||
|
* @param $src 源地址,不带?号 |
||||
|
* @param $w 宽度 |
||||
|
* @param $h 高度 |
||||
|
* @param $g 裁剪位置 nw西北 north正北 ne东北 west正西 center中间 east正东 sw西南 south正南 se东南 |
||||
|
* @param string $type 执行方式 crop:裁剪 resize:缩放 |
||||
|
*/ |
||||
|
function crop_thumb($src, $w = '', $h = '') |
||||
|
{ |
||||
|
//判断图片是不是全路径 |
||||
|
$cdn_img_host = strpos($src, 'http') !== 0 ? config('cdn_img_host') : ''; |
||||
|
if (empty($src) || !$w || !$h) { |
||||
|
return $cdn_img_host . $src; |
||||
|
} |
||||
|
//限制宽、高大小 |
||||
|
if ($w > 2000 || $w < 5 || $h > 2000 || $h < 5) { |
||||
|
return $src; |
||||
|
} |
||||
|
//有逗号分割符取第一张图片 |
||||
|
$first_pic = strstr($src, ',', true); |
||||
|
$src = !empty($first_pic) ? $first_pic : $src; |
||||
|
//拆分图片后缀 |
||||
|
$last_pos = strripos($src, '.'); //图片格式中点的位置 |
||||
|
$base_url = mb_substr($src, 0, $last_pos); //去图片后缀的url |
||||
|
$exp_url = mb_substr($src, $last_pos); //图片后缀 |
||||
|
return $cdn_img_host . $base_url . '_' . $w . 'x' . $h . $exp_url; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 判断浏览器名称和版本 |
||||
|
*/ |
||||
|
function get_client_browser() |
||||
|
{ |
||||
|
$agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : false; |
||||
|
if (!$agent) { |
||||
|
return '获取不到浏览器信息'; |
||||
|
} |
||||
|
if ((strpos($agent, 'MSIE') == false) && (strpos($agent, 'Trident') !== FALSE)) { |
||||
|
return 'Internet Explorer 11.0'; |
||||
|
} |
||||
|
if (strpos($agent, 'MSIE 10.0') != false) { |
||||
|
return 'Internet Explorer 10.0'; |
||||
|
} |
||||
|
if (strpos($agent, 'MSIE 9.0') != false) { |
||||
|
return 'Internet Explorer 9.0'; |
||||
|
} |
||||
|
if (strpos($agent, 'MSIE 8.0') != false) { |
||||
|
return 'Internet Explorer 8.0'; |
||||
|
} |
||||
|
if (strpos($agent, 'MSIE 7.0') != false) { |
||||
|
return 'Internet Explorer 7.0'; |
||||
|
} |
||||
|
if (strpos($agent, 'MSIE 6.0') != false) { |
||||
|
return 'Internet Explorer 6.0'; |
||||
|
} |
||||
|
if (strpos($agent, 'Edge') != false) { |
||||
|
return 'Edge'; |
||||
|
} |
||||
|
if (strpos($agent, '360SE') != false) { |
||||
|
return '360SE'; |
||||
|
} |
||||
|
if (strpos($agent, 'QQBrowser') != false) { |
||||
|
return 'QQBrowser'; |
||||
|
} |
||||
|
if (strpos($agent, 'Firefox') != false) { |
||||
|
return 'Firefox'; |
||||
|
} |
||||
|
if (strpos($agent, 'Chrome') != false) { |
||||
|
return 'Chrome'; |
||||
|
} |
||||
|
if (strpos($agent, 'Safari') != false) { |
||||
|
return 'Safari'; |
||||
|
} |
||||
|
if (strpos($agent, 'Opera') != false) { |
||||
|
return 'Opera'; |
||||
|
} |
||||
|
//微信浏览器 |
||||
|
if (strpos($agent, 'MicroMessage') != false) { |
||||
|
return '微信浏览器'; |
||||
|
} |
||||
|
return '未知'; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取系统类型 |
||||
|
*/ |
||||
|
function get_client_os() |
||||
|
{ |
||||
|
|
||||
|
$agent = strtolower($_SERVER['HTTP_USER_AGENT']); |
||||
|
|
||||
|
if (strpos($agent, 'windows nt')) { |
||||
|
$platform = 'Windows'; |
||||
|
} elseif (strpos($agent, 'macintosh')) { |
||||
|
$platform = 'Mac'; |
||||
|
} elseif (strpos($agent, 'ipod')) { |
||||
|
$platform = 'iPod'; |
||||
|
} elseif (strpos($agent, 'ipad')) { |
||||
|
$platform = 'iPad'; |
||||
|
} elseif (strpos($agent, 'iphone')) { |
||||
|
$platform = 'iPhone'; |
||||
|
} elseif (strpos($agent, 'android')) { |
||||
|
$platform = 'Android'; |
||||
|
} elseif (strpos($agent, 'unix')) { |
||||
|
$platform = 'Unix'; |
||||
|
} elseif (strpos($agent, 'linux')) { |
||||
|
$platform = 'Linux'; |
||||
|
} else { |
||||
|
$platform = '其他'; |
||||
|
} |
||||
|
|
||||
|
return $platform; |
||||
|
} |
||||
|
|
||||
|
// |
||||
|
|
||||
|
function htmlspecialchars_custom($str) |
||||
|
{ |
||||
|
return htmlspecialchars($str, ENT_QUOTES); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* base64_url 使用base64对字符串编码后,会出现特殊符号'+','/','=' 去除=号等特殊字符 |
||||
|
* @param $data |
||||
|
* @return string |
||||
|
*/ |
||||
|
function base64url_encode($data) { |
||||
|
|
||||
|
return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* base64_url |
||||
|
* @param $data |
||||
|
* @return false|string |
||||
|
*/ |
||||
|
function base64url_decode($data) { |
||||
|
|
||||
|
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
<?php |
||||
|
// 事件定义文件 |
||||
|
return [ |
||||
|
'bind' => [ |
||||
|
], |
||||
|
|
||||
|
'listen' => [ |
||||
|
'AppInit' => [], |
||||
|
'HttpRun' => [], |
||||
|
'HttpEnd' => [], |
||||
|
'LogLevel' => [], |
||||
|
'LogWrite' => [], |
||||
|
], |
||||
|
|
||||
|
'subscribe' => [ |
||||
|
], |
||||
|
]; |
||||
@ -0,0 +1,82 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\exception; |
||||
|
|
||||
|
use think\db\exception\DataNotFoundException; |
||||
|
use think\db\exception\ModelNotFoundException; |
||||
|
use think\Exception; |
||||
|
use think\exception\Handle; |
||||
|
use app\exception\HttpException; |
||||
|
use think\exception\HttpResponseException; |
||||
|
use think\exception\ValidateException; |
||||
|
use think\Response; |
||||
|
use Throwable; |
||||
|
|
||||
|
/** |
||||
|
* 应用异常处理类 |
||||
|
*/ |
||||
|
class ExceptionHandle extends Handle |
||||
|
{ |
||||
|
|
||||
|
private $httpStatusCode = 200; //http状态码 |
||||
|
|
||||
|
private $msg = '未知错误'; //自定义错误内容 |
||||
|
|
||||
|
private $code = 100; //自定义错误码 |
||||
|
|
||||
|
/** |
||||
|
* 不需要记录信息(日志)的异常类列表 |
||||
|
* @var array |
||||
|
*/ |
||||
|
protected $ignoreReport = [ |
||||
|
HttpException::class, |
||||
|
HttpResponseException::class, |
||||
|
ModelNotFoundException::class, |
||||
|
DataNotFoundException::class, |
||||
|
ValidateException::class, |
||||
|
]; |
||||
|
|
||||
|
/** |
||||
|
* 记录异常信息(包括日志或者其它方式记录) |
||||
|
* |
||||
|
* @access public |
||||
|
* @param Throwable $exception |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function report(Throwable $exception): void |
||||
|
{ |
||||
|
// 使用内置的方式记录异常日志 |
||||
|
parent::report($exception); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Render an exception into an HTTP response. |
||||
|
* throw new \app\exception\HttpException(309, ''); http使用方法 |
||||
|
* throw new Exception('导演',300); 异常类使用访求 |
||||
|
* @access public |
||||
|
* @param \think\Request $request |
||||
|
* @param Throwable $e |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function render($request, Throwable $e): Response |
||||
|
{ |
||||
|
// 其他错误交给系统处理 |
||||
|
if (config('app.app_debug')) { |
||||
|
return parent::render($request, $e); |
||||
|
} |
||||
|
// 添加自定义异常处理机制 |
||||
|
$this->msg = $e->getMessage() ?: $this->msg; |
||||
|
//兼容Exception类 这个类没有getStatusCode方法 |
||||
|
if ($e instanceof HttpException) { |
||||
|
$this->httpStatusCode = $e->getStatusCode() ?: $this->httpStatusCode; |
||||
|
} |
||||
|
$this->code = $e->getCode() ?: $this->code; |
||||
|
$data = [ |
||||
|
'msg' => $this->msg, |
||||
|
'data' => [], |
||||
|
'code' => $this->code, |
||||
|
]; |
||||
|
return json($data, $this->httpStatusCode); |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: yunwuxin <448901948@qq.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
declare (strict_types=1); |
||||
|
|
||||
|
namespace app\exception; |
||||
|
|
||||
|
use Exception; |
||||
|
|
||||
|
/** |
||||
|
* HTTP异常 |
||||
|
*/ |
||||
|
class HttpException extends \RuntimeException |
||||
|
{ |
||||
|
private $statusCode; |
||||
|
private $headers; |
||||
|
|
||||
|
public function __construct(int $statusCode, string $message = '', $code = 0, array $headers = [], Exception $previous = null) |
||||
|
{ |
||||
|
$this->statusCode = $statusCode; |
||||
|
$this->headers = $headers; |
||||
|
|
||||
|
parent::__construct($message, $code, $previous); |
||||
|
} |
||||
|
|
||||
|
public function getStatusCode() |
||||
|
{ |
||||
|
return $this->statusCode; |
||||
|
} |
||||
|
|
||||
|
public function getHeaders() |
||||
|
{ |
||||
|
return $this->headers; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,2 @@ |
|||||
|
<?php |
||||
|
// 这是系统自动生成的公共文件 |
||||
@ -0,0 +1,9 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 模板文件配置 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
return [ |
||||
|
|
||||
|
]; |
||||
|
|
||||
@ -0,0 +1,14 @@ |
|||||
|
<?php |
||||
|
declare (strict_types = 1); |
||||
|
|
||||
|
namespace app\index\controller; |
||||
|
|
||||
|
use think\Exception; |
||||
|
|
||||
|
class Index |
||||
|
{ |
||||
|
public function index() |
||||
|
{ |
||||
|
return '您好!这是一个[index]示例应用'; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
<?php |
||||
|
// 这是系统自动生成的event定义文件 |
||||
|
return [ |
||||
|
|
||||
|
]; |
||||
@ -0,0 +1,5 @@ |
|||||
|
<?php |
||||
|
// 这是系统自动生成的middleware定义文件 |
||||
|
return [ |
||||
|
|
||||
|
]; |
||||
@ -0,0 +1,10 @@ |
|||||
|
<?php |
||||
|
// 全局中间件定义文件 |
||||
|
return [ |
||||
|
// 全局请求缓存 |
||||
|
// \think\middleware\CheckRequestCache::class, |
||||
|
// 多语言加载 |
||||
|
// \think\middleware\LoadLangPack::class, |
||||
|
// Session初始化 |
||||
|
// \think\middleware\SessionInit::class |
||||
|
]; |
||||
@ -0,0 +1,9 @@ |
|||||
|
<?php |
||||
|
use app\ExceptionHandle; |
||||
|
use app\Request; |
||||
|
|
||||
|
// 容器Provider定义文件 |
||||
|
return [ |
||||
|
'think\Request' => Request::class, |
||||
|
'think\exception\Handle' => ExceptionHandle::class, //原系统 |
||||
|
]; |
||||
@ -0,0 +1,9 @@ |
|||||
|
<?php |
||||
|
|
||||
|
use app\AppService; |
||||
|
|
||||
|
// 系统服务定义文件 |
||||
|
// 服务在完成全局初始化之后执行 |
||||
|
return [ |
||||
|
AppService::class, |
||||
|
]; |
||||
@ -0,0 +1,51 @@ |
|||||
|
{ |
||||
|
"name": "topthink/think", |
||||
|
"description": "the new thinkphp framework", |
||||
|
"type": "project", |
||||
|
"keywords": [ |
||||
|
"framework", |
||||
|
"thinkphp", |
||||
|
"ORM" |
||||
|
], |
||||
|
"homepage": "https://www.thinkphp.cn/", |
||||
|
"license": "Apache-2.0", |
||||
|
"authors": [ |
||||
|
{ |
||||
|
"name": "liu21st", |
||||
|
"email": "liu21st@gmail.com" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "yunwuxin", |
||||
|
"email": "448901948@qq.com" |
||||
|
} |
||||
|
], |
||||
|
"require": { |
||||
|
"php": ">=8.0.0", |
||||
|
"topthink/framework": "^8.0", |
||||
|
"topthink/think-orm": "^3.0", |
||||
|
"topthink/think-filesystem": "^2.0", |
||||
|
"topthink/think-multi-app": "^1.0", |
||||
|
"topthink/think-view": "^2.0" |
||||
|
}, |
||||
|
"require-dev": { |
||||
|
"symfony/var-dumper": ">=4.2", |
||||
|
"topthink/think-trace": "^1.0" |
||||
|
}, |
||||
|
"autoload": { |
||||
|
"psr-4": { |
||||
|
"app\\": "app" |
||||
|
}, |
||||
|
"psr-0": { |
||||
|
"": "extend/" |
||||
|
} |
||||
|
}, |
||||
|
"config": { |
||||
|
"preferred-install": "dist" |
||||
|
}, |
||||
|
"scripts": { |
||||
|
"post-autoload-dump": [ |
||||
|
"@php think service:discover", |
||||
|
"@php think vendor:publish" |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 应用设置 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
return [ |
||||
|
// 应用地址 |
||||
|
'app_host' => env('APP_HOST', ''), |
||||
|
// 应用的命名空间 |
||||
|
'app_namespace' => '', |
||||
|
// 是否启用路由 |
||||
|
'with_route' => true, |
||||
|
// 默认应用 |
||||
|
'default_app' => 'index', |
||||
|
// 默认时区 |
||||
|
'default_timezone' => 'Asia/Shanghai', |
||||
|
|
||||
|
// 应用映射(自动多应用模式有效) |
||||
|
'app_map' => [], |
||||
|
// 域名绑定(自动多应用模式有效) |
||||
|
'domain_bind' => [], |
||||
|
// 禁止URL访问的应用列表(自动多应用模式有效) |
||||
|
'deny_app_list' => [], |
||||
|
|
||||
|
// 异常页面的模板文件 |
||||
|
'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl', |
||||
|
|
||||
|
// 错误显示信息,非调试模式有效 |
||||
|
'error_message' => '页面错误!请稍后再试~', |
||||
|
// 显示错误信息 |
||||
|
'show_error_msg' => true, |
||||
|
|
||||
|
]; |
||||
@ -0,0 +1,29 @@ |
|||||
|
<?php |
||||
|
|
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 缓存设置 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
return [ |
||||
|
// 默认缓存驱动 |
||||
|
'default' => 'file', |
||||
|
|
||||
|
// 缓存连接方式配置 |
||||
|
'stores' => [ |
||||
|
'file' => [ |
||||
|
// 驱动方式 |
||||
|
'type' => 'File', |
||||
|
// 缓存保存目录 |
||||
|
'path' => '', |
||||
|
// 缓存前缀 |
||||
|
'prefix' => '', |
||||
|
// 缓存有效期 0表示永久缓存 |
||||
|
'expire' => 0, |
||||
|
// 缓存标签前缀 |
||||
|
'tag_prefix' => 'tag:', |
||||
|
// 序列化机制 例如 ['serialize', 'unserialize'] |
||||
|
'serialize' => [], |
||||
|
], |
||||
|
// 更多的缓存连接 |
||||
|
], |
||||
|
]; |
||||
@ -0,0 +1,9 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 控制台配置 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
return [ |
||||
|
// 指令定义 |
||||
|
'commands' => [ |
||||
|
], |
||||
|
]; |
||||
@ -0,0 +1,20 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Cookie设置 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
return [ |
||||
|
// cookie 保存时间 |
||||
|
'expire' => 0, |
||||
|
// cookie 保存路径 |
||||
|
'path' => '/', |
||||
|
// cookie 有效域名 |
||||
|
'domain' => '', |
||||
|
// cookie 启用安全传输 |
||||
|
'secure' => false, |
||||
|
// httponly设置 |
||||
|
'httponly' => false, |
||||
|
// 是否使用 setcookie |
||||
|
'setcookie' => true, |
||||
|
// samesite 设置,支持 'strict' 'lax' |
||||
|
'samesite' => '', |
||||
|
]; |
||||
@ -0,0 +1,65 @@ |
|||||
|
<?php |
||||
|
|
||||
|
return [ |
||||
|
// 默认使用的数据库连接配置 |
||||
|
'default' => env('DB_DRIVER', 'mysql'), |
||||
|
|
||||
|
// 自定义时间查询规则 |
||||
|
'time_query_rule' => [], |
||||
|
|
||||
|
// 自动写入时间戳字段 |
||||
|
// true为自动识别类型 false关闭 |
||||
|
// 字符串则明确指定时间字段类型 支持 int timestamp datetime date |
||||
|
'auto_timestamp' => true, |
||||
|
|
||||
|
// 时间字段取出后的默认时间格式 |
||||
|
'datetime_format' => 'Y-m-d H:i:s', |
||||
|
|
||||
|
// 时间字段配置 配置格式:create_time,update_time |
||||
|
'datetime_field' => '', |
||||
|
|
||||
|
// 数据库连接配置信息 |
||||
|
'connections' => [ |
||||
|
'mysql' => [ |
||||
|
// 数据库类型 |
||||
|
'type' => env('DB_TYPE', 'mysql'), |
||||
|
// 服务器地址 |
||||
|
'hostname' => env('DB_HOST', '127.0.0.1'), |
||||
|
// 数据库名 |
||||
|
'database' => env('DB_NAME', ''), |
||||
|
// 用户名 |
||||
|
'username' => env('DB_USER', 'root'), |
||||
|
// 密码 |
||||
|
'password' => env('DB_PASS', ''), |
||||
|
// 端口 |
||||
|
'hostport' => env('DB_PORT', '3306'), |
||||
|
// 数据库连接参数 |
||||
|
'params' => [], |
||||
|
// 数据库编码默认采用utf8 |
||||
|
'charset' => env('DB_CHARSET', 'utf8mb4'), |
||||
|
// 数据库表前缀 |
||||
|
'prefix' => env('DB_PREFIX', 'bmz_'), |
||||
|
|
||||
|
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) |
||||
|
'deploy' => 0, |
||||
|
// 数据库读写是否分离 主从式有效 |
||||
|
'rw_separate' => false, |
||||
|
// 读写分离后 主服务器数量 |
||||
|
'master_num' => 1, |
||||
|
// 指定从服务器序号 |
||||
|
'slave_no' => '', |
||||
|
// 是否严格检查字段是否存在 |
||||
|
'fields_strict' => true, |
||||
|
// 是否需要断线重连 |
||||
|
'break_reconnect' => false, |
||||
|
// 监听SQL |
||||
|
'trigger_sql' => env('APP_DEBUG', true), |
||||
|
// 开启字段缓存 |
||||
|
'fields_cache' => false, |
||||
|
// 字段缓存路径 |
||||
|
'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR, |
||||
|
], |
||||
|
|
||||
|
// 更多的数据库配置信息 |
||||
|
], |
||||
|
]; |
||||
@ -0,0 +1,75 @@ |
|||||
|
<?php |
||||
|
|
||||
|
return [ |
||||
|
//登录数据字典 |
||||
|
'0' => 'ok', |
||||
|
'100' => '未知错误', |
||||
|
'101' => '数据不存在', |
||||
|
'102' => '站点不存在或已过期,请联系官方客服授权!!!', |
||||
|
'200' => 'ok', |
||||
|
'201' => '添加成功', |
||||
|
'202' => '添加失败', |
||||
|
'203' => '修改成功', |
||||
|
'204' => '修改失败或者没做任何修改', |
||||
|
'205' => '删除成功', |
||||
|
'206' => '删除失败', |
||||
|
'207' => '状态更改成功', |
||||
|
'208' => '状态更改失败', |
||||
|
'209' => '保存成功', |
||||
|
'210' => '保存失败', |
||||
|
'403' => '很抱歉您没有操作权限,请联系站点管理员!!!', |
||||
|
'500' => 'error', |
||||
|
'501' => 'error:Api控制器不存在', |
||||
|
'502' => 'error:Api方法不存在', |
||||
|
'40500' => '恭喜,登陆成功!!!', |
||||
|
'40501' => '用户名不正确!!!', |
||||
|
'40502' => '用户名不存在!!!', |
||||
|
'40503' => '该用户名已被禁用!!!', |
||||
|
'40504' => '密码不正确!!!', |
||||
|
'40505' => '未检测到正确的用户名!!!', |
||||
|
'40506' => '验证码不正确!!!', |
||||
|
'40507' => '密码错误次数过多,请半小时后重试或联系管理员!!!', |
||||
|
'40508' => '您的ip已被禁止访问,请联系管理员!!!', |
||||
|
'40509' => 'refresh_token已过期', |
||||
|
'40510' => 'token已过期', |
||||
|
'40511' => '您没有操作权限请联系站点管理员!!!', |
||||
|
'40512' => 'token无效或验证失败!!!', |
||||
|
//短信Api数据字典 |
||||
|
'40601' => '请输入正确的手机号!!!', |
||||
|
'40602' => '短信服务商数据不存在或被禁用!!!', |
||||
|
'40603' => '短信模板不存在或被禁用!!!', |
||||
|
'40604' => '请输入4位验证码!!!', |
||||
|
'40605' => '验证码不正确,请重新输入!!!', |
||||
|
|
||||
|
//数据库字典 |
||||
|
'sqlfields' => [ |
||||
|
'status' => [ |
||||
|
0 => '禁用', |
||||
|
1 => '启用', |
||||
|
], |
||||
|
'sex' => [ |
||||
|
1 => '女', |
||||
|
2 => '男' |
||||
|
], |
||||
|
/*栏目类型*/ |
||||
|
'column_type' => [ |
||||
|
0 => '列表', |
||||
|
1 => '单页', |
||||
|
2 => '外部链接', |
||||
|
3 => '留言板', |
||||
|
], |
||||
|
/*广告类型*/ |
||||
|
'ad_type' => [ |
||||
|
0 => '固定广告', |
||||
|
1 => '幻灯广告', |
||||
|
2 => '对联广告', |
||||
|
3 => '漂浮广告', |
||||
|
], |
||||
|
|
||||
|
], |
||||
|
'upload' => [ |
||||
|
'cdn_img_host' => 'http://xxxx.com/' |
||||
|
], |
||||
|
|
||||
|
|
||||
|
]; |
||||
@ -0,0 +1,24 @@ |
|||||
|
<?php |
||||
|
|
||||
|
return [ |
||||
|
// 默认磁盘 |
||||
|
'default' => 'local', |
||||
|
// 磁盘列表 |
||||
|
'disks' => [ |
||||
|
'local' => [ |
||||
|
'type' => 'local', |
||||
|
'root' => app()->getRuntimePath() . 'storage', |
||||
|
], |
||||
|
'public' => [ |
||||
|
// 磁盘类型 |
||||
|
'type' => 'local', |
||||
|
// 磁盘路径 |
||||
|
'root' => app()->getRootPath() . 'public/storage', |
||||
|
// 磁盘路径对应的外部URL路径 |
||||
|
'url' => '/storage', |
||||
|
// 可见性 |
||||
|
'visibility' => 'public', |
||||
|
], |
||||
|
// 更多的磁盘配置信息 |
||||
|
], |
||||
|
]; |
||||
@ -0,0 +1,27 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 多语言设置 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
return [ |
||||
|
// 默认语言 |
||||
|
'default_lang' => env('DEFAULT_LANG', 'zh-cn'), |
||||
|
// 允许的语言列表 |
||||
|
'allow_lang_list' => [], |
||||
|
// 多语言自动侦测变量名 |
||||
|
'detect_var' => 'lang', |
||||
|
// 是否使用Cookie记录 |
||||
|
'use_cookie' => true, |
||||
|
// 多语言cookie变量 |
||||
|
'cookie_var' => 'think_lang', |
||||
|
// 多语言header变量 |
||||
|
'header_var' => 'think-lang', |
||||
|
// 扩展语言包 |
||||
|
'extend_list' => [], |
||||
|
// Accept-Language转义为对应语言包名称 |
||||
|
'accept_language' => [ |
||||
|
'zh-hans-cn' => 'zh-cn', |
||||
|
], |
||||
|
// 是否支持语言分组 |
||||
|
'allow_group' => false, |
||||
|
]; |
||||
@ -0,0 +1,45 @@ |
|||||
|
<?php |
||||
|
|
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 日志设置 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
return [ |
||||
|
// 默认日志记录通道 |
||||
|
'default' => 'file', |
||||
|
// 日志记录级别 |
||||
|
'level' => [], |
||||
|
// 日志类型记录的通道 ['error'=>'email',...] |
||||
|
'type_channel' => ['info'=>'email'], |
||||
|
// 关闭全局日志写入 |
||||
|
'close' => false, |
||||
|
// 全局日志处理 支持闭包 |
||||
|
'processor' => null, |
||||
|
|
||||
|
// 日志通道列表 |
||||
|
'channels' => [ |
||||
|
'file' => [ |
||||
|
// 日志记录方式 |
||||
|
'type' => 'File', |
||||
|
// 日志保存目录 |
||||
|
'path' => '', |
||||
|
// 单文件日志写入 |
||||
|
'single' => false, |
||||
|
// 独立日志级别 |
||||
|
'apart_level' => [], |
||||
|
// 最大日志文件数量 |
||||
|
'max_files' => 0, |
||||
|
// 使用JSON格式记录 |
||||
|
'json' => true, |
||||
|
// 日志处理 |
||||
|
'processor' => null, |
||||
|
// 关闭通道日志写入 |
||||
|
'close' => false, |
||||
|
// 日志输出格式化 |
||||
|
'format' => '[%s][%s] %s', |
||||
|
// 是否实时写入 |
||||
|
'realtime_write' => false, |
||||
|
], |
||||
|
// 其它日志通道配置 |
||||
|
], |
||||
|
|
||||
|
]; |
||||
@ -0,0 +1,8 @@ |
|||||
|
<?php |
||||
|
// 中间件配置 |
||||
|
return [ |
||||
|
// 别名或分组 |
||||
|
'alias' => [], |
||||
|
// 优先级设置,此数组中的中间件会按照数组中的顺序优先执行 |
||||
|
'priority' => [], |
||||
|
]; |
||||
@ -0,0 +1,45 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 路由设置 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
return [ |
||||
|
// pathinfo分隔符 |
||||
|
'pathinfo_depr' => '/', |
||||
|
// URL伪静态后缀 |
||||
|
'url_html_suffix' => 'html', |
||||
|
// URL普通方式参数 用于自动生成 |
||||
|
'url_common_param' => true, |
||||
|
// 是否开启路由延迟解析 |
||||
|
'url_lazy_route' => false, |
||||
|
// 是否强制使用路由 |
||||
|
'url_route_must' => false, |
||||
|
// 合并路由规则 |
||||
|
'route_rule_merge' => false, |
||||
|
// 路由是否完全匹配 |
||||
|
'route_complete_match' => false, |
||||
|
// 访问控制器层名称 |
||||
|
'controller_layer' => 'controller', |
||||
|
// 空控制器名 |
||||
|
'empty_controller' => 'Error', |
||||
|
// 是否使用控制器后缀 |
||||
|
'controller_suffix' => false, |
||||
|
// 默认的路由变量规则 |
||||
|
'default_route_pattern' => '[\w\.]+', |
||||
|
// 是否开启请求缓存 true自动缓存 支持设置请求缓存规则 |
||||
|
'request_cache_key' => false, |
||||
|
// 请求缓存有效期 |
||||
|
'request_cache_expire' => null, |
||||
|
// 全局请求缓存排除规则 |
||||
|
'request_cache_except' => [], |
||||
|
// 默认控制器名 |
||||
|
'default_controller' => 'Index', |
||||
|
// 默认操作名 |
||||
|
'default_action' => 'index', |
||||
|
// 操作方法后缀 |
||||
|
'action_suffix' => '', |
||||
|
// 默认JSONP格式返回的处理方法 |
||||
|
'default_jsonp_handler' => 'jsonpReturn', |
||||
|
// 默认JSONP处理方法 |
||||
|
'var_jsonp_handler' => 'callback', |
||||
|
]; |
||||
@ -0,0 +1,19 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 会话设置 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
return [ |
||||
|
// session name |
||||
|
'name' => 'PHPSESSID', |
||||
|
// SESSION_ID的提交变量,解决flash上传跨域 |
||||
|
'var_session_id' => '', |
||||
|
// 驱动方式 支持file cache |
||||
|
'type' => 'file', |
||||
|
// 存储连接标识 当type使用cache的时候有效 |
||||
|
'store' => null, |
||||
|
// 过期时间 |
||||
|
'expire' => 1440, |
||||
|
// 前缀 |
||||
|
'prefix' => '', |
||||
|
]; |
||||
@ -0,0 +1,10 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Trace设置 开启调试模式后有效 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
return [ |
||||
|
// 内置Html和Console两种方式 支持扩展 |
||||
|
'type' => 'Html', |
||||
|
// 读取的日志通道名 |
||||
|
'channel' => '', |
||||
|
]; |
||||
@ -0,0 +1,25 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 模板设置 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
return [ |
||||
|
// 模板引擎类型使用Think |
||||
|
'type' => 'Think', |
||||
|
// 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法 |
||||
|
'auto_rule' => 1, |
||||
|
// 模板目录名 |
||||
|
'view_dir_name' => 'view', |
||||
|
// 模板后缀 |
||||
|
'view_suffix' => 'html', |
||||
|
// 模板文件名分隔符 |
||||
|
'view_depr' => DIRECTORY_SEPARATOR, |
||||
|
// 模板引擎普通标签开始标记 |
||||
|
'tpl_begin' => '{', |
||||
|
// 模板引擎普通标签结束标记 |
||||
|
'tpl_end' => '}', |
||||
|
// 标签库标签开始标记 |
||||
|
'taglib_begin' => '{', |
||||
|
// 标签库标签结束标记 |
||||
|
'taglib_end' => '}', |
||||
|
]; |
||||
@ -0,0 +1,2 @@ |
|||||
|
* |
||||
|
!.gitignore |
||||
@ -0,0 +1,8 @@ |
|||||
|
<IfModule mod_rewrite.c> |
||||
|
Options +FollowSymlinks -Multiviews |
||||
|
RewriteEngine On |
||||
|
|
||||
|
RewriteCond %{REQUEST_FILENAME} !-d |
||||
|
RewriteCond %{REQUEST_FILENAME} !-f |
||||
|
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] |
||||
|
</IfModule> |
||||
|
After Width: | Height: | Size: 5.3 KiB |
@ -0,0 +1,24 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: liu21st <liu21st@gmail.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
// [ 应用入口文件 ] |
||||
|
namespace think; |
||||
|
|
||||
|
require __DIR__ . '/../vendor/autoload.php'; |
||||
|
|
||||
|
// 执行HTTP应用并响应 |
||||
|
$http = (new App())->http; |
||||
|
|
||||
|
$response = $http->run(); |
||||
|
|
||||
|
$response->send(); |
||||
|
|
||||
|
$http->end($response); |
||||
@ -0,0 +1,2 @@ |
|||||
|
User-agent: * |
||||
|
Disallow: |
||||
@ -0,0 +1,19 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: liu21st <liu21st@gmail.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// $Id$ |
||||
|
|
||||
|
if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) { |
||||
|
return false; |
||||
|
} else { |
||||
|
$_SERVER["SCRIPT_FILENAME"] = __DIR__ . '/index.php'; |
||||
|
|
||||
|
require __DIR__ . "/index.php"; |
||||
|
} |
||||
@ -0,0 +1,2 @@ |
|||||
|
* |
||||
|
!.gitignore |
||||
@ -0,0 +1,13 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ] |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved. |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: liu21st <liu21st@gmail.com> |
||||
|
// +---------------------------------------------------------------------- |
||||
|
use think\facade\Route; |
||||
|
|
||||
|
|
||||
@ -0,0 +1,11 @@ |
|||||
|
<?php /*a:1:{s:41:"D:\web\wwwroot\api.ahbmz.com\app\404.html";i:1713892353;}*/ ?> |
||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<title>Title</title> |
||||
|
</head> |
||||
|
<body> |
||||
|
[自定义404] |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,10 @@ |
|||||
|
#!/usr/bin/env php |
||||
|
<?php |
||||
|
namespace think; |
||||
|
|
||||
|
// 命令行入口文件 |
||||
|
// 加载基础文件 |
||||
|
require __DIR__ . '/vendor/autoload.php'; |
||||
|
|
||||
|
// 应用初始化 |
||||
|
(new App())->console->run(); |
||||
@ -0,0 +1 @@ |
|||||
|
如果不使用模板,可以删除该目录 |
||||
Loading…
Reference in new issue