06.10.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Upgrade Guide 31<br />

Events<br />

Core Event Objects<br />

Some of the core events fired by Laravel now use event objects instead of string event names and<br />

dynamic parameters. Below is a list of the old event names and their new object based counterparts:<br />

Old | New ————- | ————- artisan.start | Illuminate\Console\Events\ArtisanStarting<br />

auth.attempting | Illuminate\Auth\Events\Attempting auth.login | Illuminate\Auth\Events\Login<br />

auth.logout | Illuminate\Auth\Events\Logout cache.missed | Illuminate\Cache\Events\CacheMissed<br />

cache.hit | Illuminate\Cache\Events\CacheHit cache.write | Illuminate\Cache\Events\KeyWritten<br />

cache.delete | Illuminate\Cache\Events\KeyForgotten connection.{name}.beginTransaction<br />

| Illuminate\Database\Events\TransactionBeginning connection.{name}.committed | Illuminate\Database\Events\TransactionCommitted<br />

connection.{name}.rollingBack | Illuminate\Database\Events<br />

illuminate.query | Illuminate\Database\Events\QueryExecuted illuminate.queue.before | Illuminate\Queue\Events\JobProcessing<br />

illuminate.queue.after | Illuminate\Queue\Events\JobProcessed<br />

illuminate.queue.failed | Illuminate\Queue\Events\JobFailed illuminate.queue.stopping |<br />

Illuminate\Queue\Events\WorkerStopping mailer.sending | Illuminate\Mail\Events\MessageSending<br />

router.matched | Illuminate\Routing\Events\RouteMatched<br />

Each of these event objects contains exactly the same parameters that were passed to the event<br />

handler in Laravel 5.1. For example, if you were using DB::listen in 5.1., you may update your code<br />

like so for 5.2.:<br />

1 DB::listen(function ($event) {<br />

2 dump($event->sql);<br />

3 dump($event->bindings);<br />

4 });<br />

You may check out each of the new event object classes to see their public properties.<br />

Exception Handling<br />

Your App\Exceptions\Handler class’ $dontReport property should be updated to include at least<br />

the following exception types:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!