3

I saw this SO question about Laravel events, but they are for Laravel 3. I've tried all of them, but none of them work. Here's my code in global.php:

$event_names = array("laravel.done", "laravel.log", "laravel.query", "laravel.resolving", "laravel.composing", "laravel.started", "laravel.controller.factory", "laravel.config.loader", "laravel.language.loader", "laravel.view.loader", "laravel.view.engine", "view.filter", "eloquent.saving", "eloquent.updated", "eloquent.created", "eloquent.saved", "eloquent.deleting", "eloquent.deleted");
foreach ($event_names as $event_name) {
    echo "Listening to {$event_name}<br/>";
    Event::listen($event_name, function($event) {
        var_dump($event);
        exit;
    }); 
}

It just starts listening, but no events fire. I've tried firing them on my own using Event::fire() and it works, but obviously that's not what I want.

Community
  • 1
  • 1
duality_
  • 17,738
  • 23
  • 77
  • 95

2 Answers2

6

I found this list in laravel wiki: http://wiki.laravel.io/Event_List_(Laravel_4)

Miguel Borges
  • 7,549
  • 8
  • 39
  • 57
  • The list is currently (22 Jan 2015) incomplete. Trying to get an account to update it, but manual approval takes time. I've compiled a (more) complete list already, if anyone is interested until then. I'll try to comment here when I get the article updated. – Dan Hunsaker Jan 22 '15 at 07:18
3

I've found the following events in Laravel 4 so far:

auth.login
auth.logout

artisan.start

illuminate.query
illuminate.log

eloquent.updating
eloquent.updated
eloquent.creating
eloquent.created

locale.changed

composing: {viewName}

I'll update this list as I find more

Laurence
  • 58,936
  • 21
  • 171
  • 212
  • Hmmm, what about the IoC that is so prevalent in the docs, couldn't it handle different event implementations? And even if it's not possible, I think that the practical benefit of the application firing events far (!) outweighs the ideological cons. – duality_ Mar 08 '13 at 16:03
  • Sorry - I've done some more investigating - check out my revised answer – Laurence Mar 08 '13 at 16:57