我在生产服务器中有一个错误,但在我的 localhost 中没有发生:
AnnotationException: [Semantical Error]
The annotation "@Sensio\Bundle\FrameworkExtraBundle\Configuration\Route" in method My\Bundle\Controller\MyController::indexAction() does not exist, or could not be auto-loaded.
当我尝试用composer更新一些包时,这个错误发生在本地,但这并没有解决,我不得不重新安装 symfony 并再次上传所有内容,并且仍在发生。
缓存已被清除,所以我想这不是缓存的事情。
应用内核.php
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new MyProject\PanelBundle\MyProjectPanelBundle(),
new MyProject\ProductBundle\MyProjectProductBundle(),
new Front\SiteBundle\FrontSiteBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
}
控制器样本
以及控制器中引发错误的注释示例:
/**
* Lists all MyEnt entities.
*
* @Route("/", name="my_ent")
* @Method("GET")
* @Template("MyProjectPanelBundle:MyEnt:index.html.twig")
*/
public function indexAction($ident)
{
应用程序/config/routing.yml
front_site:
resource: "@FrontSiteBundle/Resources/config/routing.yml"
prefix: /
MyProject_product:
resource: "@MyProjectProductBundle/Resources/config/routing.yml"
prefix: /
MyProject_panel:
resource: "@MyProjectPanelBundle/Resources/config/routing.yml"
prefix: /