Email address type for Doctrine.

v1.4.0 2020-06-06 12:35 UTC

This package is auto-updated.

Last update: 2020-08-11 11:38:57 UTC


Build Status Coverage Status Downloads this Month Latest stable


Via Composer:

$ composer require nepada/email-address-doctrine

Register the types in your bootstrap:


In Nette with nettrine/dbal integration, you can register the types in your configuration:

            Nepada\EmailAddress\RfcEmailAddress: Nepada\EmailAddressDoctrine\RfcEmailAddressType
            Nepada\EmailAddress\CaseInsensitiveEmailAddress: Nepada\EmailAddressDoctrine\CaseInsensitiveEmailAddressType


This package provides two Doctrine types:

  1. RfcEmailAddressType for storing emails represented by RfcEmailAddress.
  2. CaseInsensitiveEmailAddressType for storing emails represented by CaseInsensitiveEmailAddress.

Both types normalize the domain part of the email address before storing it in database, but they differ in handling of the local part of the address. See nepada/email-address for further details.

Example usage in the entity:

use Doctrine\ORM\Mapping as ORM;
use Nepada\EmailAddress\CaseInsensitiveEmailAddress;

 * @ORM\Entity
class Contact

    /** @ORM\Column(type=CaseInsensitiveEmailAddress::class, nullable=false) */
    private CaseInsensitiveEmailAddress $email;

    public function getEmailAddress(): CaseInsensitiveEmailAddress
        return $this->emailAddress;


Example usage in query builder:

$result = $repository->createQueryBuilder('foo')
    ->where(' = :emailAddress')
     // the parameter value is automatically normalized to
    ->setParameter('emailAddress', '', CaseInsensitiveEmailAddress::class)