Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pio.skro@gmail.com's avatar

What exactly means 'api' middleware?

I try to understand how api middleware works.

Could you help me with code references to laravel/framework repository?

How api middleware is resolved? What class/method determines that specified request is api request, and api middleware should be used? I ask for code references more than explanation.

0 likes
6 replies
pio.skro@gmail.com's avatar

@Sinnbeck Thank you but it does not explain anything. Kernel only defines what middlewares should be use. Is api resolved by Container? If yes, where api definition is binded?

What class resolves 'api? What class resolves throttle:api?

Sinnbeck's avatar

@pio.skro@gmail.com oh so this is about how the inner workings of laravel works and not how to use it in practice. I would need to do a deep dive into the code as I don't know. Never needed to. But I can say that throttle:api is throttling and is slightly different (one specific middleware, not a middleware group)

pio.skro@gmail.com's avatar

@Sinnbeck Thank you for response. I try to acquire deep understanding how Laravel guards works. As the side effect of this challenge I was finally forced to set up Xdebug. Now it should be easier.

Please or to participate in this conversation.