提交 9d750f63 编写于 作者: Y yuenblue

aaa

上级 766f17a4
{
"phpunit.phpunit": "demophpunit/vendor/bin/phpunit",
"phpunit.phpunit": "demotp6/vendor/bin/phpunit",
"phpunit.php": "php",
"phpunit.args": [
"--colors",
......
{
// 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
......@@ -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}");
});
}
......
......@@ -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();
}
}
<?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");
}
}
......@@ -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",
......
......@@ -5,6 +5,15 @@
return [
// 内置Html和Console两种方式 支持扩展
'type' => 'Html',
// 'tabs' => [
// 'base' => '基本',
// 'file' => '文件',
// 'info' => '流程',
// 'error' => '错误',
// 'sql' => 'SQL',
// 'debug' => '调试',
// 'user' => '用户',
// ],
// 读取的日志通道名
'channel' => '',
];
......@@ -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.
先完成此消息的编辑!
想要评论请 注册