我在生产服务器中出错,这在我的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 更新某些软件包并且this没有解决它时,本地发生了此错误,我不得不重新安装symfony并再次上传所有内容,和仍在发生。
缓存已被清除,所以我猜它不是缓存的东西。
<?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');
}
}
控制器中的anotattions样本会抛出错误:
/**
* Lists all MyEnt entities.
*
* @Route("/", name="my_ent")
* @Method("GET")
* @Template("MyProjectPanelBundle:MyEnt:index.html.twig")
*/
public function indexAction($ident)
{
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: /
答案 0 :(得分:0)
我有类似的问题。
使用require_once导入Sensio \ Bundle \ FrameworkExtraBundle \ Configuration \ Route类解决了它。
require_once __DIR__ . '/../vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Configuration/Route.php';