Php Yii 2有AOP吗?
我想知道每个动作执行的时间。最简单/正确的方法是使用AOP 我想要这样的东西:Php Yii 2有AOP吗?,php,yii,yii2,aop,typo3-flow,Php,Yii,Yii2,Aop,Typo3 Flow,我想知道每个动作执行的时间。最简单/正确的方法是使用AOP 我想要这样的东西: /** * @FLOW3\Before("method(.*->action.*())") */ public function markFirstTimeTag() { // Do something here. } ... /** * @FLOW3\After("method(.*->action.*())") */ public function markSecondTimeT
/**
* @FLOW3\Before("method(.*->action.*())")
*/
public function markFirstTimeTag() {
// Do something here.
}
...
/**
* @FLOW3\After("method(.*->action.*())")
*/
public function markSecondTimeTag() {
// Do something here.
}
我读到了关于我喜欢的和这个框架的文章。但这本身就是一个完整的堆栈框架
Yii 2是否有AOP模式的实现?我通常用来评测代码
Yii::trace('starting some event');
foreach(..)
{
...
}
Yii::trace('some event done');
这些跟踪可以在调试栏的日志部分找到
这可与和(未测试)结合使用
我也在文档中找到了,但我没有尝试过任何解决方案
public function beforeAction($action)
{
if (!parent::beforeAction($action)) {
return false;
}
Yii::trace($action->id.' started');
return true; // or false to not run the action
}
public function afterAction($action, $result)
{
$result = parent::afterAction($action, $result);
Yii::trace($action->id.' ended');
return $result;
}