Skip to content

Commit

Permalink
Adding some notes to event documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 7, 2013
1 parent a880077 commit e9325d4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion events.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Events

- [Basic Usage](#basic-usage)
- [Where To Register Events](#where-to-register)
- [Wildcard Listeners](#wildcard-listeners)
- [Using Classes As Listeners](#using-classes-as-listeners)
- [Queued Events](#queued-events)
Expand Down Expand Up @@ -43,6 +44,13 @@ Sometimes, you may wish to stop the propagation of an event to other listeners.
return false;
});

<a name="where-to-register"></a>
## Where To Register Events

So, you know how to register events, but you may be wondering _where_ to register them. Don't worry, this is a common question. Unfortunately, it's a hard question to answer because you can register an event almost anywhere! But, here are some tips. Again, like most other bootstrapping code, you may register events in one of your `start` files such as `app/start/global.php`.

If your `start` files are getting too crowded, you could create a separate `app/events.php` file that is included from a `start` file. This is a simple solution that keeps your event registration cleanly separated from the rest of your bootstrapping. If you prefer a class based approach, you may register your events in a [service provider](/docs/ioc#service-providers). Since none of these approaches is inherently "correct", choose an approach you feel comfortable with based on the size of your application.

<a name="wildcard-listeners"></a>
## Wildcard Listeners

Expand Down Expand Up @@ -151,4 +159,4 @@ Once the subscriber has been defined, it may be registered with the `Event` clas

$subscriber = new UserEventHandler;

Event::subscribe($subscriber);
Event::subscribe($subscriber);

0 comments on commit e9325d4

Please sign in to comment.