PHPackages                             tourze/user-id-email-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. tourze/user-id-email-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

tourze/user-id-email-bundle
===========================

用户身份电子邮箱管理模块

0.0.1(7mo ago)00MITPHPCI passing

Since Nov 10Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/tourze/user-id-email-bundle)[ Packagist](https://packagist.org/packages/tourze/user-id-email-bundle)[ RSS](/packages/tourze-user-id-email-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (28)Versions (2)Used By (0)

User ID Email Bundle
====================

[](#user-id-email-bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![PHP Version](https://camo.githubusercontent.com/04744bae0a61d2ffe29c26f07a9612eae20445fc6feaeb77b3af1f0e9be6447c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Symfony Version](https://camo.githubusercontent.com/da2318a06a50fc1c57f3067fd6250f7964bd9562d0d06bf998f24e4110634e3a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253345253344372e332d677265656e2e737667)](https://symfony.com/)[![Build Status](https://camo.githubusercontent.com/c27a457659b89ee4f1f80f7995c559dd37f2051bde7167ad25791e5c5c92cc8e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e2e737667)](#)[![Code Coverage](https://camo.githubusercontent.com/b3545ae1bcdb4ea486f71f87b43001e82dd21933bc8035d44601706c851265da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e2e737667)](#)

A Symfony bundle for managing email addresses as user identities with full ORM integration.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Dependencies](#dependencies)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Advanced Usage](#advanced-usage)
- [API Reference](#api-reference)
- [Database Schema](#database-schema)
- [Security](#security)
- [License](#license)

Features
--------

[](#features)

- **Email Identity Management**: Store and manage email addresses as user identities
- **User Association**: Link email identities to Symfony User entities
- **Identity Service**: Unified service for finding identities by type and user
- **Doctrine Integration**: Full ORM support with repository pattern
- **Timestampable**: Automatic creation and update timestamps
- **Blameable**: Track who created/updated records
- **Snowflake ID**: Unique identifier generation
- **Validation**: Built-in email format and length validation

Dependencies
------------

[](#dependencies)

This bundle requires:

- PHP 8.1 or higher
- Symfony 7.3 or higher
- Doctrine ORM 3.0 or higher
- doctrine/dbal ^4.0

Internal dependencies:

- tourze/doctrine-snowflake-bundle
- tourze/doctrine-timestamp-bundle
- tourze/doctrine-user-bundle
- tourze/user-id-bundle

Installation
------------

[](#installation)

```
composer require tourze/user-id-email-bundle
```

Add the bundle to your `config/bundles.php`:

```
return [
    // ...
    Tourze\UserIDEmailBundle\UserIDEmailBundle::class => ['all' => true],
];
```

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use Tourze\UserIDEmailBundle\Entity\EmailIdentity;
use Tourze\UserIDEmailBundle\Service\UserIdentityEmailService;

// Create email identity
$emailIdentity = new EmailIdentity();
$emailIdentity->setEmailAddress('user@example.com');
$emailIdentity->setUser($user);

// Find identity by email
$identityService = $container->get(UserIdentityEmailService::class);
$identity = $identityService->findByType('email', 'user@example.com');

// Find all identities for a user
$identities = $identityService->findByUser($user);
```

Advanced Usage
--------------

[](#advanced-usage)

### Email Validation

[](#email-validation)

The bundle automatically validates email addresses using Symfony's validation constraints:

```
use Symfony\Component\Validator\Validator\ValidatorInterface;

// Validation is automatically applied
$emailIdentity = new EmailIdentity();
$emailIdentity->setEmailAddress('invalid-email'); // Will fail validation

$violations = $validator->validate($emailIdentity);
if (count($violations) > 0) {
    foreach ($violations as $violation) {
        echo $violation->getMessage();
    }
}
```

### Custom Repository Usage

[](#custom-repository-usage)

```
use Tourze\UserIDEmailBundle\Repository\EmailIdentityRepository;

// Get repository
$repository = $entityManager->getRepository(EmailIdentity::class);

// Custom queries
$emailIdentities = $repository->findBy([
    'emailAddress' => 'user@example.com'
]);

// Find by user
$userIdentities = $repository->findBy([
    'user' => $user
]);
```

### Batch Operations

[](#batch-operations)

```
// Create multiple identities
$identities = [];
foreach ($emailAddresses as $email) {
    $identity = new EmailIdentity();
    $identity->setEmailAddress($email);
    $identity->setUser($user);
    $identities[] = $identity;
}

// Persist all at once
foreach ($identities as $identity) {
    $entityManager->persist($identity);
}
$entityManager->flush();
```

API Reference
-------------

[](#api-reference)

### EmailIdentity Entity

[](#emailidentity-entity)

- `getEmailAddress()`: Get the email address
- `setEmailAddress(string $emailAddress)`: Set the email address
- `getUser()`: Get associated user
- `setUser(UserInterface $user)`: Set associated user
- `getIdentityValue()`: Get identity value (email address)
- `getIdentityType()`: Get identity type ('email')
- `getIdentityArray()`: Get identity as array format

### UserIdentityEmailService

[](#useridentityemailservice)

- `findByType(string $type, string $value)`: Find identity by type and value
- `findByUser(UserInterface $user)`: Find all identities for a user

Database Schema
---------------

[](#database-schema)

The bundle creates a table `ims_user_identity_email` with the following structure:

- `id`: Primary key (Snowflake ID)
- `email_address`: Email address (VARCHAR 255)
- `user_id`: Foreign key to user table
- `create_time`: Creation timestamp
- `update_time`: Last update timestamp
- `create_user`: User who created the record
- `update_user`: User who last updated the record

Security
--------

[](#security)

### Email Validation

[](#email-validation-1)

This bundle implements robust email validation to prevent security issues:

- **Format Validation**: Uses Symfony's `#[Assert\Email]` to ensure valid email format
- **Length Validation**: Prevents database overflow with `#[Assert\Length(max: 255)]`
- **SQL Injection Protection**: Uses Doctrine ORM parameterized queries
- **XSS Prevention**: Email addresses are properly escaped when displayed

### Data Protection

[](#data-protection)

- **User Association**: Email identities are always linked to authenticated users
- **Audit Trail**: All changes are tracked with timestamps and user attribution
- **Access Control**: Repository methods respect Symfony's security context

### Best Practices

[](#best-practices)

1. **Always validate email addresses** before persisting
2. **Use the service layer** instead of direct entity manipulation
3. **Implement proper authorization** checks in your controllers
4. **Sanitize email inputs** in forms and APIs
5. **Monitor for suspicious patterns** in email registration

### Reporting Security Issues

[](#reporting-security-issues)

If you discover a security vulnerability, please send an email to  instead of using the issue tracker.

License
-------

[](#license)

This bundle is released under the MIT license. See the [LICENSE](LICENSE) file for details.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

235d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13899502?v=4)[tourze](/maintainers/tourze)[@tourze](https://github.com/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-user-id-email-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-user-id-email-bundle/health.svg)](https://phpackages.com/packages/tourze-user-id-email-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
