Symfony缓存预热给出了注释异常

时间:2016-12-07 22:52:48

标签: composer-php symfony php-7 php-deployer

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

  

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

功能:

供应商/奏鸣曲项目/分类束/控制器/原料药/ 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)

my composer.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;
    }

1 个答案:

答案 0 :(得分:0)

有类似的问题。 [学说\共同\注解\ AnnotationException] ...

将作曲家从版本1.3.1降级到1.2.1解决了这个问题。