The comparison between Yii and thinkphp

Source: Internet
Author: User
Tags apc yii zend framework

I small rookie one, in order to self-study and exchange PHP (Jquery,linux,lamp,shell,javascript, Server) a series of knowledge, small rookie created a group. People who wish to visit this blog can come in and talk. Seek common development. Build a platform.

My blog also has a lot of technical documents, I hope to provide you with some help.


QQ Group: 191848169 qq:450225664


This is not a review article. Just my muttered words, not to be serious. Moreover, the following content is really very miscellaneous, not comprehensive, and you can not have the same development experience with me. So for some of the traits that I'm obsessed with, you probably won't understand. Similarly, I cannot understand all of the reasons why you love a particular trait.

The background, author, and Speed of the thinkphp (TP) and Yii Framework (YII) are not covered here. Because speed is a very complex problem, there are many factors involved. I have to admit that thinkphp is an example of domestic framework operations (when fleaphp/qeephp the hottest, I said fleaphp/qeephp would pour).

Operating Environment:

    • Windows NT ACER 5.1 build 2600 (Windows XP Professional Service Pack 3) i586
    • Apache/2.2.14 (Win32) dav/2 mod_autoindex_color php/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
    • Mysql 5.1.4

Download the code:

    • Thinkphp 2.1, with extensions, samples and documentation complete package, released on May 1, 2011, is http://thinkphp.cn/Down/download/178
    • Yii 1.1.7, including framework, instance and environment detection, http://yii.googlecode.com/files/yii-1.1.7.r3135.tar.gz documents need to be downloaded separately

In culture, TP and Yii can meet the needs of Chinese users. However, since Yii is an international project, the code's comments are still in English. However, the authors of the two frameworks are Chinese (yes, the nationality of YII authors is still China), so it is convenient to exchange them.

Yii comes with an environment detection script that tells you whether the current host environment meets the needs of Yii. The content of the test is also more detailed. I think this is more convenient. TP Minimum needs PHP5.0 support, while yii minimum requires PHP 5.1.0 support. Since I use PHP 5.3, it makes no difference to me.

Yii is a purely object-oriented framework, and TP provides a series of single-letter functions. In contrast, I prefer Yii's approach because it avoids conflicts between projects.

TP in the previous version of the base class base class, at that time and a consolidation ucenter when the class conflict, once very distressed. Now the various base classes of TP are still directly named, such as the Think class. The pain of naming conflicts can be felt during project development. Yii adds the C prefix to the class of the framework (the interface is the I prefix), effectively avoiding the problem. The ccomponent in Yii is the base class for all classes, and it is useful to look at the Ccomponent code.

When it comes to naming problems, you have to say auto-import issues. The class import of TP is similar to Yii's code style. However, Yii also supports PHP namespaces and custom AutoLoad methods.

TP has a feature called Project compilation. I think it's better to use APC than to compile with the project. There is also a yiilite.php file in Yii that contains all the core classes of Yii. Yii authors say that without APC, this "compiled" file is not used because it increases overhead.

TP also in the first visit when the project automatically generated, I think this and automatic compilation, are I do not like. I am very sensitive to every addition of an if, this kind of judgment makes me very tangled. For example, TP in each run to detect the PHP version, and Yii has done a separate content of the Environment Monitoring script. Since I'm going to use this framework, I'll definitely know if I can use it in my current environment when I'm using it for the first time, so why do I have to check it every time? I said at the time that TP did too much for the user. For example, the TOPN function in the old version.

Yii's component thinking is very good, very comfortable to use. From session to cache, you can seamlessly replace all of your components without refactoring your project. Also, the delayed loading of Yii is quite thorough, and each component is loaded when it is used. For example, in TP, if the session is configured to open automatically, then TP executes Session_Start () when the application is initialized. Yii is when you use the session to open the session.

When it comes to project configuration files, TP requirements are config.php, while Yii is more flexible and supports multiple configuration files.

TP very respected its own thinkajax, now also use jquery. This point is progress.

TP makes a lot of small instances, which is worth learning from Yii. Yii is in the development of an instance site called Yii Playground (http://code.google.com/p/yiiplayground/) in this regard.

The dynamic model of TP can be realized without the need to define model. But in the actual project, I prefer to use Yii's way. By the way, defining the label in the model has brought a lot of convenience to my daily development.

The project of TP is automatically generated, and this tool is also available in Yii. And the tools are more powerful and scalable than Tp,yii.

From the TP code, one can see that the author is familiar with Java. From the Yii code, someone will find that the author is familiar with. Net. This is often a small episode that happens when people around me see the code.

Yii encapsulates a large number of page controls and class libraries, and it is a point that yii attracts me so much. This is TP short-term incomparable, in the use of TP always encounter such a problem, let me feel tp on my instead is obstruction. And Yii really is, comfortable, it is too easy to use!

The TP is far less than yii in terms of code specifications, design ideas, and class library richness. Some people say you see TP more concise, Yii is too bloated. Wrong! Simplicity and brevity are not the same thing. TP that is called simple, you read the code of YII, it is called concise. As for the bloated, look at the Zend Framework to know. (By the way, I like the Zend Framework, it is a model of learning design)

Speaking of reading code. Is it really hard for programmers? Well-read code should be a pleasure. Yii's learning curve is a little bit higher than TP, but it is nothing compared to the great advantages of yii. Moreover, I think that in the face of learning difficulties to retreat or think that yii is like a heavenly book of people, or career change it.

The above is written in a comment. Compared with TP1, the present TP2 has made a lot of progress, but there are still some problems. Contrast YII......,TP really does not have the ability to compare. Sorry to let the fans of TP disappointed.

Is that a theory? No, it's not. From the class library to the framework, to the solution. What's the best? Each person has a different word, this is because each person's thinking habits are different, the problems encountered are different, the environment is different. How can we expect everyone to have the same choice?

Or that sentence, suitable, is the best. For me, Yii is the best.


The comparison between Yii and thinkphp

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.