Explain Events and Listeners ?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

why we use Laravel - Session ?

939


How to check column is exists or not in a table using laravel?

410


Explain some features of laravel?

449


What is laravel contract?

419


List some official packages provided by laravel?

380






How to use session in laravel?

406


What is design pattern in laravel?

402


Can you exclude uris from csrf protection in laravel? Explain

426


Which template engine is used by laravel?

424


How to generate a controller with resources in laravel?

400


What is Basic Response in Laravel ?

830


Explain, how to get current environment in laravel 5?

437


What is the use of laravel framework?

437


How can we create a record in laravel using eloquent?

419


How to assign multiple middleware to laravel route ?

399