簡體   English   中英

生產服務器中的學說注釋錯誤

[英]Doctrine annotation error in production server

我在生產服務器 中出現 錯誤,該錯誤 在我的本地主機中未發生

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.

在當地這個錯誤發生時,我tryed更新一些封裝, 作曲家並沒有解決這個問題,我不得不重新安裝Symfony和重新上傳一切,仍在進行之中

緩存已清除,所以我想這不是緩存。

AppKernel.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)
{

App / 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:   /

我有類似的問題。

使用require_once導入Sensio \\ Bundle \\ FrameworkExtraBundle \\ Configuration \\ Route類可以解決此問題。

require_once __DIR__ . '/../vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Configuration/Route.php';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM