Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No mapping file found named

Error: No mapping file found named 'AppBundle.Entity.User.php' for class '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 }

I have read most of the answers i could find on google, tried all and still this error. If you need addional files, don't be afraid to ask.

like image 801
Pencho Slaveikov Avatar asked Apr 07 '26 12:04

Pencho Slaveikov


1 Answers

According to the docs:

A namespace becomes a bundle as soon as you add a bundle class to it. The bundle class name must follow these simple rules:

...
Prefix the name with the concatenation of the vendor (and optionally the category namespaces);

The Doctrine Bundle relies on this convention to find your metadata. So the namespace of your bundle should be something like YourName\AppBundle.

like image 69
user2268997 Avatar answered Apr 09 '26 00:04

user2268997