Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hpartidas's avatar

Modifying Spark user registration to include confirmation email.

Hi all,

I'm trying to modify the user registration so that the users must confirm their account.

I'm trying to use Spark::createUserWith method how ever it just won't work. I created my own CreateUser handle implementation as it's the only way for Spark not to try and pass an object to the UserRepository->create method which requires an array.

I'm really at my wits end. Has anyone attempted to modify the process and succeed?

0 likes
4 replies
ejdelmonico's avatar

I capture a Spark event and send a notification email when triggered. It was difficult to figure out how to do it but after...no problem.

I created a notification mailer and then a listener to trigger the notification when Spark broadcasted the UserSubscribed event.

1 like
hpartidas's avatar

I managed to get the registration working but was forced to use a closure instead of calling the create method on my registration class.

It feel terribly hacked and I don't like it.

I'll try it your way and see if it works out better.

Thanks for the reply!

ejdelmonico's avatar

That's good except for the technical debt created. The idea with Spark...because it is heavily opinionated...is to not modify anything or you cause yourself technical debt. Other than the settings, plans and views...I leave it all alone and use the hooks and conveniences provided by the framework. For me, capturing the event and using notifications makes for no technical debt from the framework.

hpartidas's avatar

You're 100% correct on that.

I've seen the light and will be working with events and notifications :)

Just had to shift the development paradigm in my head ;)

Please or to participate in this conversation.