0

Unlike here, I would like to hook a method into every request made to my web application. How would I do this?

Put in another way
There are some functionalities that I would want to be executed on whenever anybody checks on my web application. Most likely, I think I would put it in a method and call this method somewhere within Laravel. I don't want to write a daemon. I don't know how to do this. Please, help out. Drop a comment if you need more clarification.

Community
  • 1
  • 1
Oniya Daniel
  • 359
  • 6
  • 15

1 Answers1

3

Middleware is specifically designed to do this sort of thing. Define a middleware, then apply it globally, or to specific routes.

Prashant Pokhriyal
  • 3,727
  • 4
  • 28
  • 40
Joe
  • 4,618
  • 3
  • 28
  • 35
  • Thank you, although I had to do some more reading and experimentation with the docs... – Oniya Daniel Mar 16 '17 at 07:34
  • Moreover, you will have specify what route/controller the **middleware** should work on, but **service provider** runs throughout the whole application – Oniya Daniel Jul 09 '17 at 14:52