我是CakePHP的新手,我正在尝试使用Go!测试应用程序中的AOP。
尽管我遵循了指南并导入了Go!通过将其添加到我的composer.json中,似乎找不到AspectKernel类。
<?php
// app/ApplicationAspectKernel.php
namespace Application;
use Go\Core\AspectKernel;
use Go\Core\AspectContainer;
/**
* Application Aspect Kernel
*/
class ApplicationAspectKernel extends AspectKernel
{
/**
* Configure an AspectContainer with advisors, aspects and pointcuts
*
* @param AspectContainer $container
*
* @return void
*/
protected function configureAop(AspectContainer $container)
{
$container->registerAspect(new MonitorAspect());
}
}错误:找不到'Go\Core\AspectKernel‘类
文件: /Applications/XAMPP/xamppfiles/htdocs/test/app/Application/ApplicationAspectKernel.php
如果有人以前解决过这个问题,我很想听听你的意见。
下面是我的composer.json "require“值。
"require": {
"php": ">=5.3.0",
"ext-mcrypt": "*",
"goaop/framework": "dev-master"
},CakePHP似乎是一个非常实用的框架,我希望我可以在那里应用面向方面编程,以消除手动为函数的开始和结束放置日志的需要(以测量函数的性能)。
发布于 2017-05-26 18:54:18
看起来你把这个类放在/Applications/XAMPP/xamppfiles/htdocs/test/app中(第一行注释)并且调用了一个命名空间应用程序,尝试使用应用程序命名空间。
我要走了!在开发我的应用程序。
在/webroot/index.php中,将以下内容放在use的语句下面:
use App\ApplicationAspectKernel;
$aspect = ApplicationAspectKernel::getInstance();
$aspect->init(array(
'debug' => true, // use 'false' for production mode
'cacheDir' => dirname(__DIR__).'/tmp/aop',
'includePaths' => [
dirname(__DIR__) . '/src'
]
));我不得不在configureAop方法中忽略ApplicationAspectKernel中的@triggers注释:
protected function configureAop(AspectContainer $container) {
// use Doctrine\Common\Annotations\AnnotationReader;
AnnotationReader::addGlobalIgnoredName('triggers');
$container->registerAspect(new CacheAspect());
}https://stackoverflow.com/questions/42188995
复制相似问题