Php does not use templates. How can we achieve collaborative development between front-end and back-end personnel?

Source: Internet
Author: User
Example: the original intention of the template is to separate the code from the page. However, in actual development, the page elements of the template file must be embedded with a large number of variables, as well as processing logic such as ifelse and foreach, such as the smarty template. For this template file, the template language and html language are mixed together... example:
The original intention of the template is to separate the code from the page. However, in actual development, the page elements of the template file must be embedded with a large number of variables, as well as processing logic such as if/else and for each, such as the smarty template.
For such template files, the template language and html language are mixed, with chaotic structure, mixed logic and layout, which is not conducive to editing and production, but also to debugging and troubleshooting. At the same time, it also increases the learning pressure of front-end personnel (for example, learning smarty ).

In ideal mode, the frontend is only responsible for displaying and interacting (html, css, and js), and the backend is only responsible for providing data (php ).

How can this ideal mode be achieved?

Reply content:

Example:
The original intention of the template is to separate the code from the page. However, in actual development, the page elements of the template file must be embedded with a large number of variables, as well as processing logic such as if/else and for each, such as the smarty template.
For such template files, the template language and html language are mixed, with chaotic structure, mixed logic and layout, which is not conducive to editing and production, but also to debugging and troubleshooting. At the same time, it also increases the learning pressure of front-end personnel (for example, learning smarty ).

In ideal mode, the frontend is only responsible for displaying and interacting (html, css, and js), and the backend is only responsible for providing data (php ).

How can this ideal mode be achieved?

Today, I just saw a place where JQuery can be used. All front-end data is obtained through JQuery Ajax and Data Interaction between front-end and back-end data.

The backend outputs json and the frontend processes data.

I have written some things in this mode and hope it can be helpful.

Blog http:// I .mouto.org/
Blog http://mouto.org/

Discussion http://za2.org/

Radio station http://itorr.sinaapp.com/fm/
Radio station http://moe.re/fm

Personal spam record http://x.mouto.org/

Photo community http://dev.vscam.co/

: Why don't you give me a thumbs up with so many visits !!!!!!! T_T

Upstairs, The frontend uses ajax to receive data transmitted in json format in the background.

  • Use JSON
  • NoBackend

Let me talk about my point of view first.

PHP was originally embedded in HTML, and later templates became popular (such as Smarty). Later, it abandoned templates (using outputs) or lightweight templates (such as Laravel's Blade template engine ). However, the front and back-end code is not completely isolated. As a God-class architecture MVC for Web development, sometimes it is hard to figure out where the Business Code should be written. The so-called view is the HTML with the php chain, model is a subclass that inherits from ORM. In this mode, backend developers still need to process HTML code. Even if a person is at the frontend and backend of writing, he must constantly switch his mind between the business logic and View, which is really painful.

Only JSON is output at the backend, and JSON is processed and displayed at the front end. Therefore, the frontend and backend can be separated. However, there is no bound development mode, so it is easy for a project to get stuck with the increase in engineering quantities or code irregularities.

I highly recommend the pure REST backend + AngularJS (REST) Front-end architecture. Pure REST backend, totally abandoned View, and supports mainstream application scenarios with a single backend: apps, browsers, Web APIs, the most important thing is that there is a set of specifications or standard implementations to constrain you. the backend staff only need to consider how to be more restful and better write the API that is easy to use. AngularJS has taken advantage of the REST backend and can easily implement a very elegant front-end architecture.

With node. js, unit testing, coffee, and sass stream, it's hard to get started.

The template is actually placeholder. You do not have placeholder. How can a computer know what is changeable and what cannot be changed? The result is at most to move the template repository to the repository, and the height of the subsequent repository is based on the html structure... Back to the stone age... The template has been biased since the beginning of if-else. The more you want to compete with a general statement, the more you want to know.

You can also push the template to the front-end, and the back-end only serves as an API. However, this is just a shift of the role, and the front-end cannot display and interact with each other.

In fact, the backend should be divided into two categories: one class of zookeeper core application and the other class of zookeeper template.
Html css is called frontend CSS

The front and back-end methods are somewhat lacking and lack a middle interval.

Only in this way can we achieve the following:

The frontend is only responsible for displaying and interacting (html, css, and js), and the backend is only responsible for providing data (php ).

Because the tasks connected by the frontend and backend are handed over to the middle office ~

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.