Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9265773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:09:38+00:00 2026-06-18T14:09:38+00:00

I am using Zend Framework 2 and I have created a User Entity. Now

  • 0

I am using Zend Framework 2 and I have created a User Entity. Now I am trying to make the username field unique. However the following error is coming up.

[Semantical Error] The annotation "@UniqueEntity" in class User\Entity\User was never imported. Did you maybe forget to add a "use" statement for this annotation?

I have added this code for uniqueness check

@UniqueEntity("email")

I can see that it is a method used in Symfony. How can I use it for Zend Framework 2?

This is the Entity I am using

<?php

namespace User\Entity;

use Doctrine\ORM\Mapping as ORM,
    Zend\Form\Annotation;

/**
 * A user entity.
 *
 * @ORM\Entity
 * @ORM\Table(name="users")
 * @UniqueEntity("email")

 * @property int $id
 * @property string $username
 * @property string $email
 * @property string $password
 * 
 * @Annotation\Name("User")
 */
class User {

  /**
   * @ORM\Id
   * @ORM\Column(type="integer");
   * @ORM\GeneratedValue(strategy="AUTO")
   * 
   * @Annotation\Required(false)
   */
  protected $id;

  /**
   * @ORM\Column(type="string")
   * 
   * @Annotation\Attributes({"type":"text"})
   * @Annotation\Options({"label":"Username:"})
   * @Annotation\Filter({"name":"StringTrim"})
   * @Annotation\Filter({"name":"StripTags"})
   */
  protected $username;

  /**
   * @ORM\Column(type="string")
   * 
   * @Annotation\Attributes({"type":"text" })
   * @Annotation\Options({"label":"Email:"})
   * @Annotation\Filter({"name":"StringTrim"})
   * @Annotation\Filter({"name":"StripTags"})
   */
  protected $email;

  /**
   * @ORM\Column(type="string")
   * 
   * @Annotation\Attributes({"type":"text" })
   * @Annotation\Options({"label":"Password:"})
   * @Annotation\Filter({"name":"StringTrim"})
   * @Annotation\Filter({"name":"StripTags"})
   */
  protected $password;    

  public function __get($property) {
    return $this->$property;
  }

  /**
   * Magic setter to save protected properties.
   *
   * @param string $property
   * @param mixed $value
   */
  public function __set($property, $value) {
    $this->$property = $value;
  }

  public function getArrayCopy() {
    return array(
        'username' => $this->username,
        'email' => $this->email,
        'surname' => $this->surname,
        'first_name' => $this->first_name,
        'company' => $this->company,
        'postcode' => $this->postcode,
    );
  }

  public function populate($data) {
    $this->username = isset($data['username']) ? $data['username'] : $this->username;
  }

  public function setDate($property, $value){
    $this->$property = new \DateTime($value);
  }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:09:40+00:00Added an answer on June 18, 2026 at 2:09 pm

    @UniqueEntity is a particular extension of the symfony validation component (written as annotation here). What you are looking for is probably the validators you can find in DoctrineModule: https://github.com/doctrine/DoctrineModule/blob/master/docs/validator.md

    Support for it as annotation is not yet built-in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a login page at www.mywebsite.com/members/login I'm using Zend Framework, Now I
I'm trying to develop a site using Zend Framework, but i have a problem:
I'm starting out using the Zend Framework and have created a suitable model which
I am using Zend Framework v 1.10 I have created a custom function in
I am developing a module using zend framework and I have created a project
I have a PHP MVC application using Zend Framework. As presented in the quickstart,
i have a problem with upload mutilply files using zend framework on server actually
I have got access_token. Using zend framework. I have obtained token for multiple permissions.
All, I have a PHP Web application built using Zend Framework and MVC with
I have a Zend Framework project using version 1.10.8 with Doctrine 1.2.4.I use Zend_Auth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.