尝试从命名空间加载类“EntityRepository”

时间:2016-06-25 12:14:34

标签: symfony

我是symfony 3的初学者。我目前在安装FOSUserBundle后遇到问题。通过创建我的用户实体,我收到此错误:Error when access to app_dev.php

这是我的实体User.php:

namespace SocialclockBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;

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

我的UserRepository.php:

use Doctrine\ORM\EntityRepository;
namespace SocialclockBundle\Repository;

/**
 * UserRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class UserRepository extends EntityRepository
{
}

感谢您的帮助!!!

弗洛里安

1 个答案:

答案 0 :(得分:5)

您需要将use放在命名空间

之后
namespace SocialclockBundle\Repository;
use Doctrine\ORM\EntityRepository;