Css-using PHP as the backend language of the server, how can the web Front-end and mobile client use the same server?

Source: Internet
Author: User
Recently, we have to build a project with both clients and web Front-ends. The YII framework is used. The web Front-end is okay to say that the echo directly in the html code, sometimes even directly echo the html statement, but this is not compatible with the Android client. Could you tell me how I can achieve web-based and client-based services? Recently, I want to build a project with both clients and web Front-ends. The YII framework is used. The web Front-end is okay to say that the echo directly in the html code, sometimes even directly echo the html statement, but this is not compatible with the Android client. How can I use the same server code on the web and client?

Is json used? Asking for advice, sincerely asking for advice

Reply content:

Recently, we have to build a project with both clients and web Front-ends. The YII framework is used. The web Front-end is okay to say that the echo directly in the html code, sometimes even directly echo the html statement, but this is not compatible with the Android client. How can I use the same server code on the web and client?

Is json used? Asking for advice, sincerely asking for advice

UseAPIMechanism, regardlesswebEnd ormobileEnd, all goAPITo retrieve data.
Since we useYII, You can usebehaviorMechanismhandleManystuff.
For example, defineAPIBehaviorTo Format and process data.

However, since the subject wants to use a set of mechanisms for processing, it is necessary to ensure that the requirements are consistent. OtherwisewebNeeds to be modifiedAPI, Thenmobile.

Of course, you can put most of the logic in oneBaseAPIAnd then place the alienated code inMoblieAPIAndWebAPI.

How to designRESTful APIRefer:

Best Practices for Designing a Pragmatic RESTful API

StephenLeeIt is clear that the interface is used to transmit data (josn), and the mobile end and the web end are rendered on the front-end js in the page. The only difference is the css layout. Some features may be removed from the mobile terminal or designed separately. Json is only the data transmission format. rest is the data transmission protocol for your interface. You can use css frameworks such as boostrap3.0, but the support for earlier ie versions is very general.

I like angularjs, which is basically the same as echo. For example, the data is an object. item. name, As long as {object. item. name}. It encapsulates the template of handlebarjs. foreach and ifesle can be easily implemented. Of course there are still many js frameworks, and even jquery can be used directly.

I guess the subject development team is not strong either. I have one or two people at the backend in the previous section. I personally think backbone is a little heavy, after comparing ember and angular with backbone, I think backbone is the most important in code development. The simplest is angular :)

I am afraid to accept this because I have recovered so much separately. Give me a compliment.

Are web and Android clients all browsers? You can try bootstrap. a css/HTML framework should solve your compatibility problems.

The web Front-end can try mvc, such as ember. js and angular. js frameworks.

It is best to use a responsive front-end framework such as bootstrap. Then you can check the phonegap

The web end uses angular. js and the mobile end uses bootstrap.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.