Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yuenblue
PhpDemo
提交
9d750f63
P
PhpDemo
项目概览
yuenblue
/
PhpDemo
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PhpDemo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9d750f63
编写于
3月 28, 2024
作者:
Y
yuenblue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
aaa
上级
766f17a4
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
110 addition
and
15 deletion
+110
-15
.vscode/settings.json
.vscode/settings.json
+1
-1
.vscode/tasks.json
.vscode/tasks.json
+26
-0
demotp6/app/AppService.php
demotp6/app/AppService.php
+38
-2
demotp6/app/controller/Index.php
demotp6/app/controller/Index.php
+6
-2
demotp6/app/subscribe/Mysql.php
demotp6/app/subscribe/Mysql.php
+26
-0
demotp6/composer.lock
demotp6/composer.lock
+1
-6
demotp6/config/trace.php
demotp6/config/trace.php
+9
-0
demotp6/tests/DemoTp6.php
demotp6/tests/DemoTp6.php
+3
-4
未找到文件。
.vscode/settings.json
浏览文件 @
9d750f63
{
"phpunit.phpunit"
:
"demo
phpunit
/vendor/bin/phpunit"
,
"phpunit.phpunit"
:
"demo
tp6
/vendor/bin/phpunit"
,
"phpunit.php"
:
"php"
,
"phpunit.args"
:
[
"--colors"
,
...
...
.vscode/tasks.json
0 → 100644
浏览文件 @
9d750f63
{
//
See
https://go.microsoft.com/fwlink/?LinkId=
733558
//
for
the
documentation
about
the
tasks.json
format
"version"
:
"2.0.0"
,
"tasks"
:
[
{
"label"
:
"think run"
,
"type"
:
"shell"
,
"command"
:
"php ${workspaceRoot}/demotp6/think run"
,
"problemMatcher"
:
[],
"group"
:
{
"kind"
:
"build"
,
"isDefault"
:
true
}
},
{
"type"
:
"npm"
,
"script"
:
"build"
,
"path"
:
"demothinkcmf6/public/plugins/swagger3/vendor/zircote/swagger-php/docs"
,
"group"
:
"build"
,
"problemMatcher"
:
[],
"label"
:
"npm: build - demothinkcmf6/public/plugins/swagger3/vendor/zircote/swagger-php/docs"
,
"detail"
:
"vuepress build ."
}
]
}
\ No newline at end of file
demotp6/app/AppService.php
浏览文件 @
9d750f63
...
...
@@ -3,6 +3,10 @@ declare (strict_types = 1);
namespace
app
;
use
Monolog\Formatter\LineFormatter
;
use
Monolog\Logger
;
use
Monolog\Handler\StreamHandler
;
use
think\facade\Db
;
use
think\Service
;
use
think\facade\Event
;
/**
...
...
@@ -14,8 +18,40 @@ class AppService extends Service
{
// 服务注册
// $this->app->bind()
Event
::
listen
(
'UserLogin'
,
function
(
$user
)
{
print
"????"
;
// Event::listen('UserLogin', function($user) {
// file_put_contents("php://stdout","啊啊啊啊啊\r\n");
// file_put_contents("php://stdout","啊啊啊啊啊\r\n");
// file_put_contents("php://stdout","啊啊啊啊啊\r\n");
// file_put_contents("php://stdout","啊啊啊啊啊\r\n");
// });
// Event::listen('before_insert',function ($param) {
// echo "??????";
// });
// Event::listen('after_insert',function ($param) {
// echo "??????";
// });
// Event::subscribe("app\subscribe\Mysql");
$logger_sql
=
new
Logger
(
"logger_sql"
);
$handler
=
new
StreamHandler
(
'php://stdout'
,
Logger
::
WARNING
);
$dateFormat
=
"Y-m-d, H:i:s"
;
$output
=
"%datetime% > %level_name% > %message%
\n
"
;
// $output = "%datetime% > %level_name% > %message% %context% %extra%\n";
$formatter
=
new
LineFormatter
(
$output
,
$dateFormat
);
$handler
->
setFormatter
(
$formatter
);
$logger_sql
->
pushHandler
(
$handler
);
$this
->
app
->
bind
(
'logger_sql'
,
$logger_sql
);
Db
::
listen
(
function
(
$sql
,
$runtime
,
$master
)
{
// 进行监听处理
// file_put_contents("php://stdout","==============={$sql}===========\r\n");
/**
* @var Logger
*/
$log
=
$this
->
app
->
logger_sql
;
$master
=
$master
?
$master
:
'default'
;
$log
->
warning
(
"
{
$sql
}
Take
{
$runtime
}
By
{
$master
}
"
);
});
}
...
...
demotp6/app/controller/Index.php
浏览文件 @
9d750f63
...
...
@@ -2,6 +2,7 @@
namespace
app\controller
;
use
app\BaseController
;
use
app\model\User
;
use
think\facade\Event
;
use
think\facade\Route
;
...
...
@@ -14,8 +15,11 @@ class Index extends BaseController
public
function
hello
(
$name
=
'ThinkPHP6'
)
{
Event
::
trigger
(
"UserLogin"
,
"aaaa"
);
var_dump
(
$this
->
request
);
// $user = User::find(2);
$user
=
new
User
();
$user
->
username
=
'aaaa'
;
$user
->
password
=
'bbbb'
;
$user
->
save
();
return
Route
::
buildUrl
(
'aaaa'
,[
'name'
=>
$name
])
->
__toString
();
}
}
demotp6/app/subscribe/Mysql.php
0 → 100644
浏览文件 @
9d750f63
<?php
declare
(
strict_types
=
1
);
namespace
app\subscribe
;
class
Mysql
{
public
function
onUserLogin
(
$user
)
{
// UserLogin事件响应处理
file_put_contents
(
"php://stdout"
,
"啊啊啊啊啊
\r\n
"
);
file_put_contents
(
"php://stdout"
,
"啊啊啊啊啊
\r\n
"
);
file_put_contents
(
"php://stdout"
,
"啊啊啊啊啊
\r\n
"
);
file_put_contents
(
"php://stdout"
,
"啊啊啊啊啊
\r\n
"
);
}
public
function
onHttpRun
(
$param
){
echo
"aaaa"
;
}
public
function
onModelUserBeforeInsert
(
$param
)
{
file_put_contents
(
"php://stdout"
,
"===============
{
var_dump($param)
}
===========
\r\n
"
);
}
public
function
onBeforeUpdate
(
$param
)
{
file_put_contents
(
"php://stdout"
,
"===============
{
var_dump($param)
}
===========
\r\n
"
);
}
}
demotp6/composer.lock
浏览文件 @
9d750f63
...
...
@@ -217,7 +217,7 @@
},
"dist": {
"type": "zip",
"url": "https://
api.github.com/repos/Seldaek/monolog/zipball/437cb3628f4cf6042cc10ae97fc2b8472e48ca1f
",
"url": "https://
repo.huaweicloud.com/repository/php/monolog/monolog/2.9.2/monolog-monolog-2.9.2.zip
",
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
"shasum": ""
},
...
...
@@ -275,7 +275,6 @@
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
...
...
@@ -293,10 +292,6 @@
"logging",
"psr-3"
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/2.9.2"
},
"funding": [
{
"url": "https://github.com/Seldaek",
...
...
demotp6/config/trace.php
浏览文件 @
9d750f63
...
...
@@ -5,6 +5,15 @@
return
[
// 内置Html和Console两种方式 支持扩展
'type'
=>
'Html'
,
// 'tabs' => [
// 'base' => '基本',
// 'file' => '文件',
// 'info' => '流程',
// 'error' => '错误',
// 'sql' => 'SQL',
// 'debug' => '调试',
// 'user' => '用户',
// ],
// 读取的日志通道名
'channel'
=>
''
,
];
demotp6/tests/DemoTp6.php
浏览文件 @
9d750f63
...
...
@@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase;
use
think\facade\Cache
;
use
think\facade\Config
;
use
think\facade\Db
;
use
think\facade\Event
;
use
function
PHPUnit\Framework\assertTrue
;
class
DemoTp6
extends
TestCase
{
...
...
@@ -14,6 +14,7 @@ class DemoTp6 extends TestCase{
{
$http
=
(
new
App
())
->
setEnvName
(
'example'
)
->
http
;
$response
=
$http
->
run
();
}
function
tearDown
():
void
{
...
...
@@ -36,8 +37,6 @@ class DemoTp6 extends TestCase{
$user
->
username
=
'aaaa'
;
$user
->
password
=
'bbbb'
;
$user
->
save
();
}
function
test_modal
()
{
// assertTrue(true);
...
...
@@ -72,6 +71,6 @@ class DemoTp6 extends TestCase{
$this
->
assertNotEmpty
(
true
);
}
function
testCache
()
{
Cache
::
get
(
""
)
Cache
::
get
(
""
)
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录