php - Calling a REST API from an MVC Web Application -
i have mvc php web application needs call rest api. i'm unclear on whether should calling api controller or model? looking @ various resources i'm getting mixed information. assume should model since i'm doing dealing data , passing controller correct?
some more details clarify. have full control on rest api i'm in process of building , in php well. api leveraged ios , android companion app built team , few other apps running on proprietary devices.
the original plan web app not going leverage api , go straight db cut out overhead, several debates later , i'm leaning toward using api.
you should call web api controller. model how data passed controller view. model should have data , no business logic.
when response web api, data should put model , passed view.
the model, view , controller make mvc pattern. controller responsible putting data in model, passes view. view takes model , displays data, has been told to. there no business logic in either model or view.
ideally, put api code class library, controller uses. allows separate business logic out of website , separate component.
Comments
Post a Comment