@@ -15,7 +15,7 @@ First we define the events that happen in our system.
1515A hotel can be created with a ` name ` and an ` id ` :
1616
1717``` php
18- namespace App\Hotel\Domain\ Event;
18+ namespace App\Event;
1919
2020use Patchlevel\EventSourcing\Aggregate\Uuid;
2121use Patchlevel\EventSourcing\Attribute\Event;
@@ -33,7 +33,7 @@ final class HotelCreated
3333A guest can check in by ` name ` :
3434
3535``` php
36- namespace App\Hotel\Domain\ Event;
36+ namespace App\Event;
3737
3838use Patchlevel\EventSourcing\Attribute\Event;
3939
@@ -49,7 +49,7 @@ final class GuestIsCheckedIn
4949And also check out again:
5050
5151``` php
52- namespace App\Hotel\Domain\ Event;
52+ namespace App\Event;
5353
5454use Patchlevel\EventSourcing\Attribute\Event;
5555
@@ -75,11 +75,11 @@ In these methods the business checks are made and the events are recorded.
7575Last but not least, we need the associated apply methods to change the state.
7676
7777``` php
78- namespace App\Hotel\Domain ;
78+ namespace App\Model ;
7979
80- use App\Hotel\Domain\ Event\GuestIsCheckedIn;
81- use App\Hotel\Domain\ Event\GuestIsCheckedOut;
82- use App\Hotel\Domain\ Event\HotelCreated;
80+ use App\Event\GuestIsCheckedIn;
81+ use App\Event\GuestIsCheckedOut;
82+ use App\Event\HotelCreated;
8383use Patchlevel\EventSourcing\Aggregate\Uuid;
8484use Patchlevel\EventSourcing\Attribute\Aggregate;
8585use Patchlevel\EventSourcing\Attribute\Apply;
@@ -173,11 +173,11 @@ we need a projection for it. To create a projection we need a projector.
173173Each projector is then responsible for a specific projection.
174174
175175``` php
176- namespace App\Hotel\Infrastructure\Projection ;
176+ namespace App\Subscribers ;
177177
178- use App\Hotel\Domain\ Event\GuestIsCheckedIn;
179- use App\Hotel\Domain\ Event\GuestIsCheckedOut;
180- use App\Hotel\Domain\ Event\HotelCreated;
178+ use App\Event\GuestIsCheckedIn;
179+ use App\Event\GuestIsCheckedOut;
180+ use App\Event\HotelCreated;
181181use Illuminate\Database\Schema\Blueprint;
182182use Illuminate\Support\Facades\DB;
183183use Illuminate\Support\Facades\Schema;
@@ -251,9 +251,17 @@ final class HotelProjection
251251 }
252252}
253253```
254- !!! warning
255254
256- autoconfigure need to be enabled, otherwise you need add the `event_sourcing.subscriber` tag.
255+ You need to register the projector in the ` event-sourcing.php ` configuration file.
256+
257+ ``` php
258+ return [
259+ 'subscribers' => [
260+ App\Subscribers\HotelProjector::class,
261+ ],
262+ ];
263+
264+ ```
257265
258266!!! note
259267
@@ -264,14 +272,14 @@ final class HotelProjection
264272In our example we also want to send an email to the head office as soon as a guest is checked in.
265273
266274``` php
267- namespace App\Hotel\Application\Processor ;
275+ namespace App\Subscribers ;
268276
269- use App\Hotel\Domain\ Event\GuestIsCheckedIn;
277+ use App\Event\GuestIsCheckedIn;
270278use Illuminate\Support\Facades\Mail;
271279use Patchlevel\EventSourcing\Attribute\Processor;
272280
273281#[Processor('admin_emails')]
274- final class SendCheckInEmailListener
282+ final class SendCheckInEmailProcessor
275283{
276284 #[Subscribe(GuestIsCheckedIn::class)]
277285 public function onGuestIsCheckedIn(GuestIsCheckedIn $event): void
@@ -280,10 +288,18 @@ final class SendCheckInEmailListener
280288 }
281289}
282290```
283- !!! warning
284291
285- autoconfigure need to be enabled, otherwise you need add the `event_sourcing.subscriber` tag.
286-
292+ You need to register the processor in the ` event-sourcing.php ` configuration file.
293+
294+ ``` php
295+ return [
296+ 'subscribers' => [
297+ App\Subscribers\SendCheckInEmailProcessor::class,
298+ ],
299+ ];
300+
301+ ```
302+
287303!!! note
288304
289305 You can find out more about processor in the [library](https://event-sourcing.patchlevel.io/latest/subscription/)
@@ -295,8 +311,8 @@ We are now ready to use the Event Sourcing System. We can load, change and save
295311``` php
296312namespace App\Hotel\Infrastructure\Controller;
297313
298- use App\Hotel\Domain \Hotel;
299- use App\Hotel\Infrastructure\Projection \HotelProjection;
314+ use App\Model \Hotel;
315+ use App\Subscribers \HotelProjection;
300316use Illuminate\Http\Request;
301317use Illuminate\Http\Response;
302318use Patchlevel\EventSourcing\Aggregate\Uuid;
0 commit comments