Zend-framework-What is the difference between a frame and a template, such as PHP's Zend Framework and Smarty

Source: Internet
Author: User
Tags php programming language what php codeigniter zend framework
Frameworks are generally used for larger projects, and templates generally apply to smaller projects, so is that right? So what else is there besides that?

Reply content:

Frameworks are generally used for larger projects, and templates generally apply to smaller projects, so is that right? So what else is there besides that?

The framework is a faster and more convenient way to develop applications, and now the mainstream PHP framework supports the development of MVC patterns.
M is "model" (can be understood as the operation of the database),
V is "view views" (used to output front-end data),
C is "controller controllers" (back-end logic, back-end operations),
This allows the front end, back end, database logic to be separated, easy to develop

The controller outputs data from the model to the view, such as
I want to output a word on the front page: "Hello, xxx"
The following XXX needs to be replaced with the user name in the database, read the database data through the controller, save the user name into the variable $user_name.
Different template engines have different syntax rules, such as the one I filled out in the template

Hello, {$user _name}

Through the template engine processing, you can easily output the final page.

The general framework will have a template engine, which is part of V. or using the open source template engine, Smarty is the more famous one

Split Line

Update at 2012-09-05 15:53:48

Let's give MVC an example below, in fact, I am also a novice don't call me master ... ⊙﹏⊙ b

For example, we do a simple message system, there is only one field, is the content of the message
To implement two of the simplest features:
1. Show message content
2. Submit a message

The traditional way of development, all the code (SQL, PHP, HTML) are written together, the project is relatively large when it is not easy to maintain

Now let's comb the logic of the two functions
1. Show message content
Logic: User access->php processing (C) read the database (M), Display message content page (V)

2. Submit a message
Logic: User submitted->php processing (C)-write Database (M)-Display results page (message succeeded) (V)

M is to directly manipulate the database. For example, you can filter out the JS code in the message data.

This example is very simple, actually do not C also line, for example, we can judge in C that the access IP is not in the blacklist, do not read the database, directly display the error page.

Finally, for example, we save the database read the message data in the variable $content, output it to the template, according to the different template engine to write the template, such as

Message content: {$content}

You'll understand what MVC means when you develop a formal project, and MVC is just a concept, no hard rules, and not bound by MVC.
Or in practice, it is recommended to choose a framework, self-development of small projects.

The domestic open source framework:

    • thinkphp:http://thinkphp.cn
    • Speedphp:http://www.speedphp.com
    • lazyphp:http://ftqq.com/lazyphp/

The open source framework abroad:

    • yiiframework:http://www.yiiframework.com/
    • cakephp:http://cakephp.org/
    • codeigniter:http://codeigniter.org.cn/

The framework and template are different concepts.

The concept of the framework (this refers to the web framework) can refer to wikis, and note the bold text:

a Web application framework is a software framework, which is designed to support the development of dynamic websites, Web applications and Web services. The framework aims to alleviate the overhead associated and common activities performed in WEB development. For example, many frameworks provide libraries for database access, templating frameworks and session Managemen T, and they often promote code reuse.

The concept of template is as follows:

A Web Template system describes the software and methodologies used to produce WEB pages and for deployment on WEBSI TES and delivery over the Internet.such systems process Web templates, using a template engine.

A good description of the work of the template:

Smarty Official website Why use Smarty also has the description:

Some might argue that Smarty does what PHP can does already: separate the presentationfrom business logic. The PHP programming language is great for code development if mixed with HTML, the syntax of PHP statements can be A mess to manage. Smarty makes up to the insulating PHP from the presentation with a much simpler tag-based syntax. The tags reveal application content, enforcing a clean separation from PHP code. No PHP knowledge is required to manage Smarty templates.

The framework is like a skeleton, and the template is just part of the bone.

Reference Links:
Web Template System Http://en.wikipedia.org/wiki/Web_temp ...
WEB Application Framework Http://en.wikipedia.org/wiki/Web_appl ...
Why use Smarty? Http://www.smarty.net/why_use

Let me say something simple:

Smarty is a template engine, the advantage of template engine is that when the background business logic changes, the page template can not need or even rarely follow the change, also when the page template changes, the background business code may not need to follow the changes.

The Zend framework is a framework that typically contains models, views, and controls. A model defines a data structure that is used to pass a request to the appropriate view, and the view is the definition of what is to be presented. When the data is transferred to the template engine, the template engine translates it into a user interface.

Example:
Zhang San is a frame, you ask him what he answers, but he speaks of alien language, human cannot understand. Template engine is a universal translator, can translate alien language into different human languages, although the language is not the same, but the expression of the same meaning.

Well, that's it.

I have done many training in 2007 to 2012, the content is "PHP Web Application Architecture Evolution", ppt in this: Http://weibo.com/1779910713/yhXYRoqpZ

See the difference between the template and the frame after reading the estimate

  • Related Article

    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.