Home > Backend Development > PHP Tutorial > Website architecture issues

Website architecture issues

WBOY
Release: 2016-08-10 09:07:23
Original
991 people have browsed it

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>
Copy after login
Copy after login

Then on the PC page, just write this on the template:

<code>{{ userlist = Tag_User_getList() }}
// ....</code>
Copy after login
Copy after login

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.

Reply content:

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>
Copy after login
Copy after login

Then on the PC page, just write this on the template:

<code>{{ userlist = Tag_User_getList() }}
// ....</code>
Copy after login
Copy after login

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.

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template