Property (...) does not exist (Symfony 3)

In my Symfony 3 project, I have a ManyToMany relationship between “users” and “roles”.

It worked, but now I have an error:

Property AppBundle\Entity\Role::$user does not exist

I do not know what I did, probably due to running the command "php bin / console doctrine: mapping: import --force AppBundle xml".

Here is a snippet of a user entity class:

/**
 * @ORM\Table(name="user")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
 */
class User implements AdvancedUserInterface, \Serializable {

    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     *
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Role", cascade = {"persist"})
     * @ORM\JoinTable(name="user_role")
     */
    private $roles;

As you can see, there is a relation to the Role object.

The essence of the role, on the other hand, does not contain any correlation information, and it should work in accordance with this article:

https://knpuniversity.com/screencast/symfony2-ep3/many-to-many-relationship

and it worked, and now it doesn’t have a clue why.

, " ManyToMany" Symfony. .

+4
2

, AppBundle/Resources/config/doctrine, . . .

, " ".

config/doctrine, , , , .

+6

@Cerad, . (php bin/console cache:clear), !

symfony.com/doc/current/console/usage.html

0

Source: https://habr.com/ru/post/1626868/


All Articles