Home >Backend Development >PHP Tutorial >Website architecture issues
Currently, our website has four mobile terminals (IOS, ANDROID, PC, TV). In addition to the PC terminal, other terminals access and obtain data through the api json data format, but the PC terminal does not, unless for example some lists Pages, etc. use API, and other PC pages are generated directly in the background when rendering the page. Then the problem we encounter now is that the interfaces required by these four terminals are incomprehensible. Even if the interfaces are the same, the data structures or fields are different. How to deal with this? Our current approach is to use the MVC model on the server side, plus a Lib library. For the interface, we just call the classes and methods in the lib in the controller. For the PC, we have implemented a simple label, which is actually indirect access. class, for example, if I want to get the user list, it looks like this in the controller that provides the home address:
<code>// ..... $userList = User::getList() return $this->success($userList);</code>
Then on the PC page, just write this on the template:
<code>{{ userlist = Tag_User_getList() }} // ....</code>
Basically, it is a structure like this, but this has many disadvantages. For example, it is not possible to separate the PC side from the mobile side. Secondly, the data required by the mobile side is not necessarily required by the PC side. Vice versa, it may cause reading Get some unused data, etc.
Then I would like to ask how they solve this problem in some large projects? For example, Taobao, JD.com, etc.
Currently, our website has four mobile terminals (IOS, ANDROID, PC, TV). In addition to the PC terminal, other terminals access and obtain data through the api json data format, but the PC terminal does not, unless for example some lists Pages, etc. use API, and other PC pages are generated directly in the background when rendering the page. Then the problem we encounter now is that the interfaces required by these four terminals are incomprehensible. Even if the interfaces are the same, the data structures or fields are different. How to deal with this? Our current approach is to use the MVC model on the server side, plus a Lib library. For the interface, we just call the classes and methods in the lib in the controller. For the PC, we have implemented a simple label, which is actually indirect access. class, for example, if I want to get the user list, it looks like this in the controller that provides the home address:
<code>// ..... $userList = User::getList() return $this->success($userList);</code>
Then on the PC page, just write this on the template:
<code>{{ userlist = Tag_User_getList() }} // ....</code>
It is basically a structure like this, but this has many disadvantages. For example, it is not possible to separate the PC side from the mobile side. Secondly, the data required by the mobile side is not necessarily required by the PC side. Vice versa, it may cause reading Get some unused data, etc.
Then I would like to ask how they solve this problem in some large projects? For example, Taobao, JD.com, etc.
You say that, you have no idea what is going on with your website? It seems that 4 websites are forced together. Since each has its own interface, why should we unify the interface? If the current data consistency is achieved, then don't worry about the interface problem, major changes are impossible. It will be ok to filter out unnecessary fields at the interface. Don't do anything more in-depth. It's already a mess, and the more you change it, the more messy it becomes.
Personally, I think the API interface should be as standardized as possible when designing...one set of interfaces, multiple calls.