2017-05-05 20 views
0

我需要一點幫助。Symfony - 如何解決缺少註釋的原則問題?

實體:

<?php 

namespace UserBundle\Entity; 

use FOS\UserBundle\Model\User as BaseUser; 
use Doctrine\ORM\Mapping as ORM; 
use Symfony\Component\Validator\Constraints as Assert; 
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; 
use Doctrine\ORM\Mapping\Index; 


/** 
* User 
* 
* @ORM\Table(name="system_user") 
* @ORM\Entity(repositoryClass="UserBundle\Entity\Repository\UserRepository") 
*/ 
class User extends BaseUser 
{ 
    /** 
    * @var int 
    * 
    * @ORM\Column(name="id", type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    protected $id; 
... 
} 

教義看到與標註的問題。我檢查了所有可以找到的問題,但沒有一個解決方案無法解決我的問題。

錯誤:

[Semantical Error] The annotation "@Doctrine\ORM\Mapping\Table" in class UserBundle\Entity\User does not exist, or could not be auto-loaded. 

autoload.php:

<?php 

use Doctrine\Common\Annotations\AnnotationRegistry; 
use Composer\Autoload\ClassLoader; 

/** @var ClassLoader $loader */ 
$loader = require __DIR__.'/../vendor/autoload.php'; 

AnnotationRegistry::registerLoader(array($loader, 'loadClass')); 

return $loader; 

作曲:

{ 
    "name": "...", 
    "license": "Commercial", 
    "type": "project", 
    "description": "...", 
    "autoload": { 
     "psr-4": { "": "src/" }, 
     "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] 
    }, 
    "require": { 
     "php": ">=5.3.9", 
     "symfony/symfony": "2.8.*", 
     "doctrine/orm": "^2.4.8", 
     "doctrine/doctrine-bundle": "~1.4", 
     "symfony/swiftmailer-bundle": "~2.3,>=2.3.10", 
     "symfony/monolog-bundle": "^3.0.2", 
     "sensio/distribution-bundle": "~5.0", 
     "sensio/framework-extra-bundle": "~3.0", 
     "incenteev/composer-parameter-handler": "~2.0", 
     "friendsofsymfony/user-bundle": "[email protected]", 
     "friendsofsymfony/jsrouting-bundle": "^1.5", 
     "ocramius/proxy-manager": "2.0.*", 
     "doctrine/doctrine-migrations-bundle": "^1.1", 
     "nelmio/security-bundle": "^1.8", 
     "willdurand/faker-bundle": "^1.3", 
     "nelmio/api-doc-bundle": "^2.13", 
     "sonata-project/admin-bundle": "3.3", 
     "sonata-project/doctrine-orm-admin-bundle": "3.0", 
     "acseo/change-password-bundle": "dev-master#9c42fab1aa67e0b2211e37832bf3a2a398cb9b42", 
     "snc/redis-bundle": "^1.1", 
     "knplabs/knp-paginator-bundle": "^2.5", 
     "liip/imagine-bundle": "^1.5", 
     "egeloen/ckeditor-bundle": "^4.0", 
     "jms/serializer-bundle": "^1.1", 
     "phpoffice/phpexcel": "^1.8", 
     "ftrrtf/rollbar-bundle": "^0.15.1", 
     "knplabs/knp-snappy-bundle": "^1.4", 
     "iio/libmergepdf": "~3.0", 
     "php-amqplib/rabbitmq-bundle": "^1.10", 
     "darsyn/ip": "3.3.*", 
     "thadafinser/user-agent-parser": "2.0.0", 
     "friendsofphp/php-cs-fixer": "^1.11", 
     "browscap/browscap-php": "^3.0", 
     "donatj/phpuseragentparser": "^0.5.0", 
     "endorphin-studio/browser-detector": "^3.0", 
     "handsetdetection/php-apikit": "^4.1.10", 
     "jenssegers/agent": "^2.3", 
     "mobiledetect/mobiledetectlib": "^2.7.5", 
     "piwik/device-detector": "^3.6", 
     "sinergi/browser-detector": "^6.0", 
     "ua-parser/uap-php": "^3.4.3", 
     "whichbrowser/parser": "^2.0.10", 
     "woothee/woothee": "^1.2", 
     "mimmi20/wurfl": "^1.7.1.1", 
     "zsxsoft/php-useragent": ">=1.2,<1.4" 
    }, 
    "require-dev": { 
     "sensio/generator-bundle": "~3.0", 
     "symfony/phpunit-bridge": "~2.7", 
     "phing/phing": "^2.14", 
     "phpunit/phpunit": "5.3.*", 
     "squizlabs/php_codesniffer": "^2.6", 
     "phploc/phploc": "^3.0", 
     "phpmd/phpmd": "^2.4", 
     "sebastian/phpcpd": "^2.0" 
    }, 
    "scripts": { 
     "symfony-scripts": [ 
      "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-install-cmd": [ 
      "@symfony-scripts" 
     ], 
     "post-update-cmd": [ 
      "@symfony-scripts" 
     ] 
    }, 
    "config": { 
     "bin-dir": "bin" 
    }, 
    "extra": { 
     "symfony-app-dir": "app", 
     "symfony-web-dir": "web", 
     "symfony-assets-install": "relative", 
     "incenteev-parameters": { 
      "file": "app/config/parameters.yml" 
     }, 
     "branch-alias": { 
      "dev-master": "2.8-dev" 
     } 
    } 
} 

我會很高興,如果有人將解決這個問題。我不能。

+0

嘗試添加 框架: 驗證:{enable_annotations:真正} 在您的應用程序/配置/ config.yml –

+0

請問你composer.json看? –

+0

@Sylvain我已經在框架中設置了驗證。 – paxi

回答

0

我認爲沒有人能解決這個問題,所以我貼我的contenf從config.yml:

framework: 
    #esi:    ~ 
    translator:  { fallbacks: ["%locale%"] } 
    secret:   "%secret%" 
    router: 
     resource: "%kernel.root_dir%/config/routing.yml" 
     strict_requirements: ~ 
    form:   ~ 
    csrf_protection: ~ 
    validation:  { enable_annotations: true } 
    #serializer:  { enable_annotations: true } 
    templating: 
     engines: ['twig'] 
    default_locale: "%locale%" 
    trusted_hosts: ~ 
    trusted_proxies: ~ 
    session: 
     # handler_id set to null will use default session handler from php.ini 
     handler_id: session.handler.native_file 
     save_path: '%kernel.root_dir%/../var/sessions' 
    fragments:  ~ 
    http_method_override: true 

# Twig Configuration 
twig: 
    debug:   "%kernel.debug%" 
    strict_variables: "%kernel.debug%" 

# Doctrine Configuration 
doctrine: 
    dbal: 
     driver: pdo_mysql 
     host:  "%database_host%" 
     port:  "%database_port%" 
     dbname: "%database_name%" 
     user:  "%database_user%" 
     password: "%database_password%" 
     charset: UTF8 
     types: 
      ip: Darsyn\IP\Doctrine\IpType 
    orm: 
     auto_generate_proxy_classes: "%kernel.debug%" 
     naming_strategy: doctrine.orm.naming_strategy.underscore 
     class_metadata_factory_name: Doctrine\ORM\Mapping\ClassMetadataFactory 
     default_repository_class: Doctrine\ORM\EntityRepository 
     auto_mapping: true 
     resolve_target_entities: 
      FOS\UserBundle\Model\User: UserBundle\Entity\User 
0

你嘗試清算和氣候變暖的你在運行這個環境中的緩存?

php app/consle cache:clear -e test 
php app/consle cache:warmup -e test 
+0

是的,問題是史詩般的。我從master複製了app_dev.php(在那個時候,但現在是3.4版本),註釋沒有從'../app//autoload.php'自動加載。 ;) – paxi