Download the PHP package makraz/verify-email-change-bundle without Composer

On this page you can find all versions of the php package makraz/verify-email-change-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package verify-email-change-bundle

Makraz Verify Email Change Bundle

A Symfony bundle that provides secure email address change functionality with verification.

Features

Installation

The bundle supports Symfony Flex auto-discovery and will be registered automatically. If you're not using Flex, enable it manually:

Quick Start

Step 1: Update Your User Entity

Your User entity must implement EmailChangeableInterface:

Note: EmailChangeableInterface only requires getId(), getEmail(), and setEmail().

Step 2: Create the Database Table

Run the following command to create the migration:

Or create the table manually:

Step 3: Configure the Bundle (Optional)

Step 4: Create Your Controller

Displaying Pending Email Changes

The bundle provides Twig functions to easily display pending email change status in your templates.

Using Twig Functions (Recommended)

Available Twig Functions

How It Works

Flow Diagram

API Reference

EmailChangeHelper

generateSignature()

validateTokenAndFetchUser()

confirmEmailChange()

Returns the user's old email address.

cancelEmailChange()

hasPendingEmailChange()

getPendingEmail()

Maintenance

Purging Expired Requests

Expired email change requests remain in the database until purged. Use the built-in console command to clean them up:

Recommended: Add a cron job or Symfony Scheduler task to purge regularly:

Or with Symfony Scheduler:

Events

The bundle dispatches events for extensibility:

EmailChangeInitiatedEvent

Dispatched when an email change request is initiated.

EmailChangeConfirmedEvent

Dispatched when an email change is confirmed.

EmailChangeCancelledEvent

Dispatched when an email change is cancelled.

Security

Dual Verification Mode

For high-security applications, enable dual verification to require confirmation from both the old and new email addresses:

When enabled, generateSignature() returns an EmailChangeDualSignature with two URLs:

Handle old email verification in your controller:

Max Verification Attempts

The bundle automatically invalidates verification links after a configurable number of failed attempts (default: 5):

After exceeding the limit, a TooManyVerificationAttemptsException is thrown and the request is removed.

CSRF Protection for Cancel Endpoint

The bundle provides a CsrfTokenHelper to protect the cancel endpoint:

In your Twig template:

Security Recommendations

  1. Always require password confirmation before initiating an email change
  2. Enable dual verification (require_old_email_confirmation: true) for sensitive applications
  3. Use CSRF protection on the cancel endpoint (see above)
  4. Send a notification to the old email address when an email change is initiated
  5. Keep verification link lifetimes short (1 hour is recommended)
  6. Set up the purge command as a cron job to clean expired requests
  7. Use HTTPS for all verification URLs (the bundle uses UrlGeneratorInterface::ABSOLUTE_URL)
  8. Monitor events — listen to EmailChangeInitiatedEvent for audit logging

Email Notifications

The bundle includes an optional EmailChangeNotifier service that handles sending verification and notification emails using the built-in Twig templates.

Enabling the Notifier

Using the Notifier

Customizing Email Templates

Override the default templates by creating files in your project:

Translations

The bundle includes translations for exception messages and email templates in:

Translations are loaded automatically. To override them, create your own translation files:

API / Headless Mode

For SPA, mobile apps, and API-first applications, use the EmailChangeResponseFactory to generate consistent JSON responses:

OTP Verification

For mobile apps and API flows, use numeric OTP codes instead of signed URL links:

Audit Events

The EmailChangeAuditEvent provides security-relevant information for logging:

Available actions: initiated, verified, confirmed, cancelled, failed_verification, max_attempts_exceeded, expired_access, old_email_confirmed.

Storage Backends

The bundle supports multiple storage backends. The default is database (Doctrine ORM).

Database (default)

Uses Doctrine ORM to persist email change requests. Requires doctrine/orm and doctrine/doctrine-bundle.

Stateless

Uses a PSR-6 cache pool (Redis, Memcached, filesystem, etc.) instead of a database. Ideal for applications that don't use Doctrine ORM or want faster lookups. Requires a CacheItemPoolInterface service and a user provider callback.

In-Memory (Testing)

The InMemoryEmailChangeRequestRepository is intended for testing. Register it as a service manually:

Custom Adapter

Implement EmailChangeRequestRepositoryInterface and point the configuration to your service:

When storage_service is set, it takes precedence over the storage option.

Configuration Reference

Exception Reference

All exceptions implement VerifyEmailChangeExceptionInterface.

Exception When Message
SameEmailException New email equals current email "The new email address is identical to the current one."
EmailAlreadyInUseException Email taken by another user "This email address is already in use."
TooManyEmailChangeRequestsException Request too soon after previous "You have already requested an email change..."
TooManyVerificationAttemptsException Max attempts exceeded "Too many verification attempts (max: N)."
ExpiredEmailChangeRequestException Verification link expired "The email change link has expired."
InvalidEmailChangeRequestException Invalid or tampered link Varies

Upgrading

From v1.4 to v2.0

Breaking changes:

New features:

Migration:

From v1.3 to v1.4

New features (non-breaking):

No database migration required.

From v1.2 to v1.3

New features (non-breaking):

No database migration required. Enable the notifier in configuration if desired.

From v1.1 to v1.2

New features (non-breaking):

Database migration required: The email_change_request table has new columns:

Or use Doctrine migrations:

From v1.0 to v1.1

Interface change (non-breaking):

Testing

License

This bundle is released under the MIT License. See the LICENSE file for details.

Support

For issues, questions, or contributions, please visit: https://github.com/makraz/verify-email-change-bundle


All versions of verify-email-change-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
symfony/framework-bundle Version ^6.4|^7.0|^8.0
symfony/security-core Version ^6.4|^7.0|^8.0
symfony/http-foundation Version ^6.4|^7.0|^8.0
symfony/routing Version ^6.4|^7.0|^8.0
symfony/event-dispatcher Version ^6.4|^7.0|^8.0
symfony/translation Version ^6.4|^7.0|^8.0
twig/twig Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package makraz/verify-email-change-bundle contains the following files

Loading the files please wait ...