Unable to disable automatic SendEmailVerificationNotification listener registration in Laravel 11+ using new application bootstrapping API
#57390
Unanswered
clarkewing
asked this question in
Ideas
Replies: 2 comments
-
The idea is to simplify the whole bootstrapping, but I don't believe what you're doing is a hack as more advanced requirements may require additional setup. Moving this to Idea, but feel free to send a PR to add an API to configure and see how Taylor feels about it. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@clarkewing this should go into the documentation as a proper solution |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
12.21.0
PHP Version
8.4.13
Description
Context
Laravel 11 introduced automatic registration of the
SendEmailVerificationNotificationlistener for theRegisteredevent.The upgrade guide suggests disabling this behavior by defining an empty
configureEmailVerification()method in an application's ownEventServiceProvider.However, with the new application bootstrapping API, this is no longer feasible in practice:
Application::configure()internally callsApplicationBuilder::withEvents()Illuminate\Foundation\Support\Providers\EventServiceProvider, which in turn registers theSendEmailVerificationNotificationlistener before the application can override itconfigureEmailVerification()in an application's ownEventServiceProviderhas no effect unless the developer manually reimplements the application bootstrap sequence and removes thewithEvents()callThis has been brought up in #50783, #51187, and #52601, but I believe we're in a different situation here because of the issue with the new application bootstrapping API.
Workaround
To work around this, I had to bypass
Application::configure()entirely and rebuild the boot sequence manually to prevent Laravel from registering the default event provider:This does work, but it feels like a hack and goes against the new application bootstrapping API's intention of providing a clean and fluent configuration layer.
Proposal:
There should be a supported way to disable this automatic listener registration using the new bootstrap API — possibly via something like
‑>withoutAuthEvents(), or a configurable method parameter?Steps To Reproduce
Install a fresh Laravel 11+ application using the new application bootstrapping API (
bootstrap/app.php)Implement a
Usermodel that implementsMustVerifyEmailAttempt to disable automatic email verification by defining an empty
configureEmailVerification()method in yourApp\Providers\EventServiceProvider, as suggested in the upgrade guide:Register a new user (
/register)Expected: No
VerifyEmailnotification email is dispatchedActual: Laravel still dispatches a
VerifyEmailnotification email via theSendEmailVerificationNotificationlistenerBeta Was this translation helpful? Give feedback.
All reactions