Debreker Debreker - 1 month ago 20
PHP Question

Symfony production Mapping Exception FOSUserBundle

I have searched on stackoverflow for my problem, but I have not found an answer for my problem.

Currently I'm deploying my symfony project on my Debian server running PHP 5.6.26 following the documentation on the symfony website.

When I executed the command for installing my bundles by running the command

composer install --no-dev --optimize-autoloader


I get the following error:


[Doctrine\ORM\Mapping\MappingException]
Class "AppBundle\Entity\User" sub class of "FOS\UserBundle\Model\User" is not a valid entity or mapped super class.


I'm not having this error on my development machine's (Windows 10 desktop and a Macbook)

Currently I have no clue of what could be wrong. I did switch from annotation to yml later in the project.

My
User.php
file:

<?php

namespace AppBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;

/**
* User
*/
class User extends BaseUser
{

public function __construct()
{
parent::__construct();
}

protected $id;

/**
* @var \AppBundle\Entity\Address
*/
private $address;


/**
* Set address
*
* @param \AppBundle\Entity\Address $address
*
* @return User
*/
public function setAddress(\AppBundle\Entity\Address $address = null)
{
$this->address = $address;

return $this;
}

/**
* Get address
*
* @return \AppBundle\Entity\Address
*/
public function getAddress()
{
return $this->address;
}
}


and my User.orm.yml file:

AppBundle\Entity\User:
type: entity
table: user
repositoryClass: AppBundle\Repository\UserRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
lifecycleCallbacks: { }

oneToOne:
address:
targetEntity: AppBundle\Entity\Address
cascade: ["persist", "remove"]

Answer

After seeing the answer of Alvin Bunk, I saw that the folder Resources (in src/AppBundle) was capitalized in his answer. After checking, my folder Resources was not capitalized.

my fix: Capitalize the folder Resources in src/AppBundle/

Comments