Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created May 7, 2012 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymcmahon/2627741 to your computer and use it in GitHub Desktop.
Save coreymcmahon/2627741 to your computer and use it in GitHub Desktop.
<?php
namespace MyCompany\BlogBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/* Include the required validators */
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/* Note below: we can make assertions at the class / entity level */
/**
* MyCompany\BlogBundle\Entity\User
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="MyCompany\BlogBundle\Entity\UserRepository")
*
* @UniqueEntity("email")
* @UniqueEntity("username")
*/
class User
{
/**
* @var string $username
*
* @ORM\Column(name="username", type="string", length=255)
*
* @Assert\MinLength(
* limit=5,
* message="Username must have at least {{ limit }} characters."
* )
* @Assert\MaxLength(
* limit=50,
* message="Username must have at most {{ limit }} characters."
* )
*/
private $username;
/**
* @var string $email
*
* @ORM\Column(name="email", type="string", length=255)
*
* @Assert\Email(
* message = "The value '{{ value }}' is not a valid email."
* )
*/
private $email;
/**
* @var string $password
*
* @ORM\Column(name="password", type="string", length=31)
*
* @Assert\MinLength(
* limit=5,
* message="Password must have at least {{ limit }} characters."
* )
* @Assert\MaxLength(
* limit=50,
* message="Password must have at most {{ limit }} characters."
* )
*/
private $password;
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/*
* Getters and setters omitted for brevity...
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment