使用ReflectionClass记录日志方法

记录一下啊使用php反射特性来记录操作日志

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

$re = new ReflectionClass(CLASS);
$doc = $re->getMethod($request->action())->getDocComment();
if (empty($doc)) {
throw new Exception('请给控制器方法注释');
}
preg_match('/\s(\w+)/u', $re->getMethod($request->action())->getDocComment(), $values);
$notes = $values[0];


/**
* 测试操作
*/
public function test() {
echo "test";
}