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

abdulbasit-web's avatar

Structuring Laravel Project

How to structure a laravel project (e-commerce), that provide APIs for both mobile and front-end(next.js) what i think is Api/v1/mobile controllers Api/v1/frontend controller is that a good way? or what a better structure?

0 likes
2 replies
JussiMannisto's avatar

I'd try to make the APIs client-agnostic. There's no need to maintain separate sets of endpoints that do the same thing. Only create separate controllers when needed, e.g. if you use different login flows on native apps and browsers.

As for the controller directory structure, it doesn't matter much until your app grows big. Just make it make sense, you can always refactor it later. I usually put authentication/authorization stuff under Auth, admin endpoints under Admin etc.

1 like

Please or to participate in this conversation.