Statamic v3 - Understanding Event Listeners

Hi everyone,

I’m trying to wrap my head around Statamic V3 Events listener.

For exemple, I would like to listen to the form Submission event. (FormSubmitted) https://statamic.dev/extending/events#formsubmitted

I did something like this without any good result:

Step 1:

Referring to the Laravel documentation, I have to register the listener in the app/EventServiceProvider.php.

    protected $listen = [
        'Statamic\Events\FormSubmitted' => [
            'Statamic\Events\AddMailchimpUser',
        ]
    ];


Step 2:

I run the terminal

php artisan event:generate


That commande generate the folders structure in /app.

app/Event/Statamic/Events/FormSubmitted.php 
app/Listeners/Statamic/Events/AddMailchimpUser.php


I have zero idea if what i’m doing is right.

Can someone help me understand how to listen to Statamic V3 events?

Many thanks!

Answered by Simon Bédard!
>>>>>>> Answered <<<<<<<
6 Replies
2 Followers