InterviewSolution
| 1. |
Explain Events in Laravel. |
|
Answer» Event is an action that’s been recognised by the program and can be handled by the program itself. Laravel EVENTS work on Observer- subscriber pattern. Laravel event CLASSES are stored in app/Events directory whereas listeners are stored in app/listeners directory. Events decouple various aspect of application SINCE a SINGLE event can handle multiple listeners that are independent. Let’s understand with an example: When a system receives payment of an order you WOULD like to trigger a notification. With the introduction of the event here, you need not to couple payment processing code rather just need to raise an event PaymentReceived and listener can receive and generate a notification. Event can be generated via Artisan command. php artisan event generate. |
|