nepada / email-address-doctrine
Email address type for Doctrine.
Installs: 8 800
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/nepada/email-address-doctrine
Requires
- php: >=8.1.0 <8.6
- doctrine/dbal: ^3.0@dev || ^4.0@dev
- nepada/email-address: ^2.3@dev || ^3.0@dev
Requires (Dev)
- composer-runtime-api: ^2.0
- composer/semver: 3.4.4
- mockery/mockery: 1.6.12
- nepada/coding-standard: 8.0.1
- nepada/phpstan-nette-tester: 2.0.1
- nette/tester: 2.5.6
- nette/utils: >=3.2.7
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpstan/phpstan: 2.1.29
- phpstan/phpstan-mockery: 2.0.0
- phpstan/phpstan-nette: 2.0.6
- phpstan/phpstan-strict-rules: 2.0.7
- shipmonk/phpstan-rules: 4.2.1
- spaze/phpstan-disallowed-calls: 4.6.0
README
Installation
Via Composer:
$ composer require nepada/email-address-doctrine
Register the types in your bootstrap:
\Doctrine\DBAL\Types\Type::addType( \Nepada\EmailAddress\RfcEmailAddress::class, \Nepada\EmailAddressDoctrine\RfcEmailAddressType::class ); \Doctrine\DBAL\Types\Type::addType( \Nepada\EmailAddress\CaseInsensitiveEmailAddress::class, \Nepada\EmailAddressDoctrine\CaseInsensitiveEmailAddressType::class );
In Nette with nettrine/dbal integration, you can register the types in your configuration:
dbal: connection: types: Nepada\EmailAddress\RfcEmailAddress: Nepada\EmailAddressDoctrine\RfcEmailAddressType Nepada\EmailAddress\CaseInsensitiveEmailAddress: Nepada\EmailAddressDoctrine\CaseInsensitiveEmailAddressType
Usage
This package provides two Doctrine types:
RfcEmailAddressTypefor storing emails represented byRfcEmailAddress.CaseInsensitiveEmailAddressTypefor storing emails represented byCaseInsensitiveEmailAddress.
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\Column; use Doctrine\ORM\Mapping\Entity; use Nepada\EmailAddress\CaseInsensitiveEmailAddress; #[Entity] class Contact { #[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') ->select('foo') ->where('foo.email = :emailAddress') // the parameter value is automatically normalized to example@example.com ->setParameter('emailAddress', 'Example@Example.com', CaseInsensitiveEmailAddress::class) ->getQuery() ->getResult();