Explain Events and Listeners ?



Explain Events and Listeners ?..

Answer / surbhi

Events and Listeners serve a great way to decouple a web application, since one event can have multiple listeners which are independent of each other.
The events folder created by the artisan command includes the following two files
1. : event.php
2. :SomeEvent.php.

Event.php

<?php
namespace AppEvents;
abstract class Event{
//
}
As mentioned above, event.php includes the basic definition of class Event and calls for namespace AppEvents. Please note that the user defined or custom events are created in this file.


SomeEvent.php

For example, if we need to initialize order variable in the constructor for registering an event, we can do it in the following way -

public function __construct(Order $order)
{
$this->order = $order;
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Laravel PHP Framework Interview Questions

Explain how to create a controller in laravel?

0 Answers  


Explain the concept of cookies.

0 Answers  


What is the difference between namespace and use in laravel?

0 Answers  


Tell me is laravel an open source?

0 Answers  


What is meant by Laravel - Encryption ?

1 Answers  






How to add a middleware in route group?

1 Answers  


What are the difference between insert() and insertgetid() in laravel?

0 Answers  


In laravel, what is fillable attribute in a model?

0 Answers  


How to create view Laravel - File Uploading ?

1 Answers  


Explain loggin in laravel.

0 Answers  


How to configure route cache in laravel?

0 Answers  


Explain me what is your favorite feature of laravel?

0 Answers  


Categories