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

In order to run laravel. What permissions are required to be on storage and the bootstrap/cache directories?

0 Answers  


What do you mean by laravel mix?

0 Answers  


Do you know what version of laravel do you generally use?

0 Answers  


Where is the authentication configuration file is located in laravel?

0 Answers  


What is artisan in laravel?

0 Answers  


How to generate pretty urls in laravel?

0 Answers  


Is laravel better than wordpress?

0 Answers  


How do I register an artisan command?

0 Answers  


What is route model binding in laravel?

0 Answers  


How to pass multiple variables by controller to blade file?

1 Answers  


Tell me is laravel an open source?

0 Answers  


How can someone change the default database type in laravel?

0 Answers  


Categories