Skip to content

Commit

Permalink
Add important note about middleware terminate method
Browse files Browse the repository at this point in the history
If middleware is not registered as singleton within container and it has terminate method, laravel will create a new instance of your middleware and call terminate on that instance, losing your previous instance properties.
  • Loading branch information
ifeltsweet committed Jul 20, 2015
1 parent 2e8ac2a commit daf16c2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,5 @@ Sometimes a middleware may need to do some work after the HTTP response has alre
}

The `terminate` method should receive both the request and the response. Once you have defined a terminable middleware, you should add it to the list of global middlewares in your HTTP kernel.

> **Note:** You must bind your middleware class to container as singleton if you want your `terminate` method to be called on the same instance as the `handle` method.

0 comments on commit daf16c2

Please sign in to comment.