错误:找不到名为' AppBundle.Entity.User.php'的映射文件。对于课程' AppBundle \ Entity \ User'。
user.php的
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Doctrine\ORM\EntityManager;
/**
* @ORM\Entity
* @ORM\Table(name="accounts")
*/
class User
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=256)
*/
protected $email;
/**
* @ORM\Column(type="string", length=32)
*/
protected $alias;
/**
* @ORM\Column(type="string", length=128)
* @Assert\NotBlank()
*/
protected $password;
/**
* @ORM\Column(type="datetime")
*/
protected $created_at;
/**
* @ORM\Column(type="datetime")
*/
protected $updated_at;
/**
* @ORM\Column(type="int", length=5)
*/
protected $currency;
/**
* @ORM\Column(type="int", length=5)
*/
protected $alternative_currency;
/**
* @ORM\Column(type="int", length=2)
*/
protected $level;
/**
* @ORM\Column(type="int", length=10)
*/
protected $exp;
/**
* @ORM\Column(type="string", length=10)
*/
protected $activation_code;
/**
* @ORM\Column(type="string", length=10)
*/
protected $recovery_key;
/**
* @ORM\Column(type="datetime")
*/
protected $recovery_time;
/**
* @ORM\Column(type="int", length=1)
*/
protected $tutorial;
/**
* @ORM\Column(type="int", length=1)
*/
protected $last_zone;
/**
* @ORM\Column(type="int", length=1)
*/
protected $chat_status;
protected $remember_me;
protected $em;
public function getEmail(){
return $this->email;
}
public function setEmail($email){
$this->email = $email;
}
public function getPassword(){
return $this->password;
}
public function setPassword($password){
$this->password = $password;
}
public function getAlias(){
return $this->alias;
}
public function setAlias($alias){
$this->alias = $alias;
}
public function getCreatedAt(){
return $this->created_at;
}
public function setCreatedAt($created_at) {
$this->created_at = $created_at;
}
public function getUpdatedAt(){
return $this->updated_at;
}
public function setUpdatedAt($updated_at) {
$this->updated_at = $updated_at;
}
public function getCurrency(){
return $this->currency;
}
public function setCurrency($currency){
$this->currency = $currency;
}
public function getAlternativeCurrency(){
return $this->alternative_currency;
}
public function setAlternativeCurrency($alternative_currency){
$this->alternative_currency = $alternative_currency;
}
public function getLevel(){
return $this->level;
}
public function setLevel($level){
$this->level = $level;
}
public function getExp(){
return $this->exp;
}
public function setExp($exp){
$this->exp = $exp;
}
public function getActivationCode(){
return $this->activation_code;
}
public function setActivationCode($activation_code){
$this->activation_code = $activation_code;
}
public function getRecoveryKey(){
return $this->recovery_key;
}
public function setRecoveryKey($recovery_key){
$this->recovery_key = $recovery_key;
}
public function getRecoveryTime(){
return $this->recovery_time;
}
public function setRecoveryTime($recovery_time){
$this->recovery_time = $recovery_time;
}
public function getTutorial(){
return $this->tutorial;
}
public function setTutorial($tutorial){
$this->tutorial = $tutorial;
}
public function getLastZone(){
return $this->last_zone;
}
public function setLastZone($last_zone){
$this->last_zone = $last_zone;
}
public function getChatStatus(){
return $this->chat_status;
}
public function setChatStatus($chat_status){
$this->chat_status = $chat_status;
}
public function getRememberMe(){
return $this->remember_me;
}
public function setRememberMe($remember_me){
$this->remember_me = $remember_me;
}
}
config.yml:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true, enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
我已经阅读了我可以在谷歌上找到的大部分答案,尝试了所有并且仍然是这个错误。如果您需要附加文件,请不要害怕询问。
答案 0 :(得分:0)
根据docs:
只要向其添加捆绑类,命名空间就会成为捆绑包。 bundle类名必须遵循以下简单规则:
...
使用供应商的串联(以及可选的类别命名空间)作为名称前缀;
Doctrine Bundle依赖此约定来查找元数据。因此,您的包的名称空间应该类似于YourName\AppBundle
。