Composer php Symfony缓存预热导致注释异常

Composer php Symfony缓存预热导致注释异常,composer-php,symfony,php-7,php-deployer,Composer Php,Symfony,Php 7,Php Deployer,我正在使用deployer.org工具,使用默认的symfony3配方。 prod环境上的缓存预热任务出现以下错误: [RuntimeException][Doctrine\Common\Annotations\AnnotationException] [语义错误]注释 方法中的“@Nelmio\ApiDocBundle\Annotation\ApiDoc” Sonata\ClassificationBundle\Controller\Api\CategoryController::getCat

我正在使用deployer.org工具,使用默认的symfony3配方。 prod环境上的缓存预热任务出现以下错误:

[RuntimeException][Doctrine\Common\Annotations\AnnotationException] [语义错误]注释 方法中的“@Nelmio\ApiDocBundle\Annotation\ApiDoc” Sonata\ClassificationBundle\Controller\Api\CategoryController::getCategoriesAction()不存在,或无法自动加载

职能:

供应商/sonata项目/classification bundle/Controller/Api/CategoryController.php

使用Nelmio\ApiDocBundle\Annotation\ApiDoc

/**
     * Retrieves the list of categories (paginated) based on criteria.
     *
     * @ApiDoc(
     *  resource=true,
     *  output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}}
     * )
     *
     * @return PagerInterface
     */
    public function getCategoriesAction(ParamFetcherInterface $paramFetcher)
mycomposer.json

{
  "name": "symfony/framework-standard-edition",
  "license": "MIT",
  "type": "project",
  "description": "The \"Symfony Standard Edition\" distribution",
  "autoload": {
    "psr-4": {
      "": "src/"
    },
    "classmap": [
      "app/AppKernel.php",
      "app/AppCache.php"
    ]
  },
  "require": {
    "php": "^7.0",
    "symfony/symfony": "3.2.*",
    "doctrine/orm": "^2.5",
    "doctrine/doctrine-bundle": "^1.6",
    "doctrine/doctrine-cache-bundle": "^1.2",
    "symfony/swiftmailer-bundle": "^2.3",
    "symfony/monolog-bundle": "^2.8",
    "sensio/distribution-bundle": "^5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "^2.0",
    "phpspec/prophecy": "^1.3",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "sonata-project/doctrine-orm-admin-bundle": "^3.0",
    "fresh/doctrine-enum-bundle": "~4.6",
    "hautelook/alice-bundle": "^1.3",
    "knplabs/knp-menu-bundle": "^2.0",
    "beberlei/DoctrineExtensions": "^1.0",
    "sonata-project/media-bundle": "^3.3",
    "ob/highcharts-bundle": "^1.5",
    "twig/extensions": "^1.3",
    "dms/twig-extension-bundle": "^1.2",
    "liip/imagine-bundle": "^1.6",
    "stof/doctrine-extensions-bundle": "^1.2",
    "deployer/deployer": "^4.0"
  },
  "require-dev": {
    "sensio/generator-bundle": "^3.0",
    "symfony/phpunit-bridge": "^3.0",
    "phpunit/phpunit": "4.8.*",
    "doctrine/doctrine-fixtures-bundle": "^2.3",
    "deployer/recipes": "^4.0"
  },
  "scripts": {
    "post-install-cmd": [
      "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ],
    "post-update-cmd": [
      "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ]
  },
  "config": {
    "bin-dir": "bin"
  },
  "extra": {
    "symfony-app-dir": "app",
    "symfony-bin-dir": "bin",
    "symfony-var-dir": "var",
    "symfony-web-dir": "web",
    "symfony-tests-dir": "tests",
    "symfony-assets-install": "relative",
    "incenteev-parameters": {
      "file": "app/config/parameters.yml"
    }
  }
}
我的AppKernel:

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 Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            new Sonata\CoreBundle\SonataCoreBundle(),
            new Sonata\BlockBundle\SonataBlockBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
            new Sonata\AdminBundle\SonataAdminBundle(),
            new Fresh\DoctrineEnumBundle\FreshDoctrineEnumBundle(),
            new DMS\Bundle\TwigExtensionBundle\DMSTwigExtensionBundle(),
            new Liip\ImagineBundle\LiipImagineBundle(),
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),

            new EschBundle\EschBundle()
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
            $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();

        }

        return $bundles;
    }



    public function getRootDir()
    {
        return __DIR__;
    }

    public function getCacheDir()
    {
        return $this->getVarOrShmDir('/cache/'.$this->getEnvironment());
    }

    public function getLogDir()
    {
        return $this->getVarOrShmDir('/logs');
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
    }

    private function getVarOrShmDir($dir)
    {
        $result = dirname(__DIR__) . '/var/' . $dir;

        if (in_array($this->environment, ['dev', 'test'], true) && is_dir('/dev/shm')
        ) {
            $result = '/dev/shm/mijnbuur/' . $dir . '/';
        }

        return $result;
    }
他也有类似的问题。 [Doctrine\Common\Annotations\AnnotationException]


将composer从1.3.1版降级到1.2.1版解决了此问题。

您可以发布控制器的代码吗?最多方法和use语句添加了函数和我的AppKernel,这样您就可以看到我正在使用的所有捆绑包。尝试启用Nelmio捆绑包,在AppKernel类中添加行
new Nelmio\ApiDocBundle\NelmioApiDocBundle()
,如果尚未加载捆绑包,请从cli启动命令:
composer require nelmio/api doc bundle
仍然存在相同的错误,似乎是外部捆绑包中的错误。您可以在此处下载较旧版本的composer