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

EbrahemSamer's avatar

How to seperate the web code and API Code ?

I build a web application, I've controllers and models.

I need to build an API for this application and I do not have problems in Controllers.

I'd do something like that, Controllers\API\MyApiControllers.php This is for controllers.

The Question is How to seperate The models Code.

Should I have Seperate API Methods with the default App methods and relations and accessors... ??

Thanks.

0 likes
1 reply

Please or to participate in this conversation.