Route Groups -> Each route to execute common code?


#1

I like the idea of route groups. Is it possible somehow in Slim that each route function in a group execute some common code at the start of each function?

Instead of having a copy of the code in each function, can the code be in one place, and all the routes execute that code?

Basically I want to add some extra security and if it fails return null. I don’t want to put that code in all the functions in the group.

Thanks.


#2

Hi @jcatlga

I think a Group Middleware is what you’re looking for.