Mvc-LaravelvsCakePHPvsCodeIgniter (performance, development efficiency, and debt capability)

Source: Internet
Author: User
Tags kohana
Recently, I plan to use a relatively medium-sized PHP application and think of a more widely used MVC framework. {Code...} Yii2 and symfony2 are too large and not suitable. LaravelCakePHPKohanaCI is taken into account. First let's talk about these three frameworks {code ...} segm... recently, I plan to use a relatively medium-sized PHP application and think of a more widely used MVC framework.
Requirements

1. Support namespace 2. do not support the PHP43. architecture, performance is more important 4. Long-term stability, rather than the framework that will soon be eliminated or disbanded

Yii2 and symfony2 are too large to fit. Consider Laravel CakePHP Kohana CI.
First, let's talk about these three frameworks.

1) on the CI 2.x official website, a discard status CI framework is too lightweight, and many things must be done by yourself. The CI framework is very old and cannot be tracked in the IDE, clicking the class name cannot jump to the past 2) Why does CakePHP 2.x have to be backward compatible with PHP4? We have to use a lame App: use () to replace namespace! To be compatible with PHP4, the entire architecture is messy. If CakePHP is not compatible with PHP4, more people should use it. 3) Laravel does not support php4, and namespace is widely praised on the Internet, I think that every evaluation article is copied and pasted.

There are comparisons of frameworks on the Internet, including segmentfault, but they are basically excerpted and reproduced, rather than the actual experience after use. We look forward to a real experience after use, instead of copying and pasting the online evaluation.

Using Laravel today, we found that the documentation is not as rich as the official publicity, but not very clear. All Route methods have those, so they cannot be found. The official documents are just a few simple examples, which are not detailed at all.

Supplement:
Once again, I have used CodeIgniter and ThinkPHP all the way to Yii2 and developed some complete projects. Now I find that the MVC pattern of PHP is indeed difficult to meet the requirements. The later component, now the idea of laravel is hard to understand, and I always feel like catching up, especially tired.

In fact, at the beginning, I had taken too many detours. Many years ago, I had a strong rejection and extreme resistance against OOP, because using the class would lead to a very slow program running, the root cause is that the running environment I use is really bad, and the virtual host is not as good as win. In later MVC mode, the number of files loaded was almost incomparable. Later, I started to use the MVC framework, and the common host was completely unable to support it. Most of the virtual hosts were win servers, and PHP had a maximum of PHP5.3, A large batch is still in PHP5.0 (the virtual host provides only one FTP user name and password ).

Having gone through too many detours, it has always been bound by hardware conditions and operating environments.

Reply content:

Recently, I plan to use a relatively medium-sized PHP application and think of a more widely used MVC framework.
Requirements

1. Support namespace 2. do not support the PHP43. architecture, performance is more important 4. Long-term stability, rather than the framework that will soon be eliminated or disbanded

Yii2 and symfony2 are too large to fit. Consider Laravel CakePHP Kohana CI.
First, let's talk about these three frameworks.

1) on the CI 2.x official website, a discard status CI framework is too lightweight, and many things must be done by yourself. The CI framework is very old and cannot be tracked in the IDE, clicking the class name cannot jump to the past 2) Why does CakePHP 2.x have to be backward compatible with PHP4? We have to use a lame App: use () to replace namespace! To be compatible with PHP4, the entire architecture is messy. If CakePHP is not compatible with PHP4, more people should use it. 3) Laravel does not support php4, and namespace is widely praised on the Internet, I think that every evaluation article is copied and pasted.

There are comparisons of frameworks on the Internet, including segmentfault, but they are basically excerpted and reproduced, rather than the actual experience after use. We look forward to a real experience after use, instead of copying and pasting the online evaluation.

Using Laravel today, we found that the documentation is not as rich as the official publicity, but not very clear. All Route methods have those, so they cannot be found. The official documents are just a few simple examples, which are not detailed at all.

Supplement:
Once again, I have used CodeIgniter and ThinkPHP all the way to Yii2 and developed some complete projects. Now I find that the MVC pattern of PHP is indeed difficult to meet the requirements. The later component, now the idea of laravel is hard to understand, and I always feel like catching up, especially tired.

In fact, at the beginning, I had taken too many detours. Many years ago, I had a strong rejection and extreme resistance against OOP, because using the class would lead to a very slow program running, the root cause is that the running environment I use is really bad, and the virtual host is not as good as win. In later MVC mode, the number of files loaded was almost incomparable. Later, I started to use the MVC framework, and the common host was completely unable to support it. Most of the virtual hosts were win servers, and PHP had a maximum of PHP5.3, A large batch is still in PHP5.0 (the virtual host provides only one FTP user name and password ).

Having gone through too many detours, it has always been bound by hardware conditions and operating environments.

CakePHP never commented.

The growth process of a php programmer is often analogous to CI-> Laravel-> CI. CI and Laravel can basically be considered as the dominant PHP framework in the past few years and now, with the highest usage. CI is suitable for beginners and masters. Laravel is suitable for medium-level programmers to increase productivity.

Details

CI provides few things, which is precisely the most important reason for its undefeated position.

In addition, CI documentation is simply a model of open source software, which is very clear and detailed!

It can give us the core functions, let us truly understand the essence of php web, feel the true charm of MVC. BTW, don't underestimate MVC. It is the most popular structure that has been tested and tested by modern GUI software development. It can be understood without looking at MVC. We need to do it, feel it.

Laravel claimed to have completely imitated Rails and had to admit that they did, including performance. Pai_^ Laravel is actually in line with the development characteristics of Internet products: Quickly Make available products, and then fast iteration.

If Laravel is used, you do not need to worry about performance issues because when performance problems occur, performance is not a problem. Some users have money and time, and they want to figure out how to reconstruct it ~

Many of your analyses are incorrect.

(1) EllisLab did try to find someone to connect to the CI, but in fact, the CI update on github has never stopped.

(2) cakephp 2. x only supports php 5.x, does not support php 4.x, and supports php 4. x is cakephp 1.x, cakephp 2. x does not need a namespace because the namespace is available only after php 5.3, and the original php community planned to put these features in php 6. only cakephp 3 is supported for php 5.4. The official version is coming soon. cakephp is certainly the first choice if you prioritize the medium-and long-term stability. It is still being maintained and only supports php 4. x cakephp 1. version x bug fixes.

(3) If you think yii2 and symfony are big, Laravel should not be considered. This is built on a large number of symfony components, but is the size really so important? Currently, it is not more than 10 years ago that 1 MB space is 1 ~ 2RMB era, isn't it?

Updated on April 9, July 20: The latest Yii2 already supports read/write splitting and one write database and multiple slave databases. It also supports multiple write databases and multiple slave databases!

He does not agree with the topic's statement about the Yii2's huge size. Laravel counts the third-party code on which he depends, which is more than the Yii2 file. Furthermore, it is superficial to determine whether a framework is huge from the size of a file.

In fact, Yii2 is very flexible, and most components can be replaced. You can read their latest documents. Yii2 itself can be embedded into your original code, if you want to use AR, load the AR component. (In fact, this function was provided in the Yii1 era. At the beginning, I used the Yii1 model component easily in my own project, however, the project was abandoned due to the chaotic architecture and other reasons ).

Yii2 is fully functional and has been actively absorbing excellent features from other frameworks. For example, AssetBundle and WebDebug of symfony2 are very useful functions. Then there are two components of the background artifact Gii + GridView. To cope with most Background Development, it is easy to click twice, and it will be OK after the change, and the DataProvider component is also very practical. In short, most of the functions Yii used in web development provide you with ready-made functions. You only need to use them. If it is not easy to use, you can inherit a change, then replace it in the configuration and it will be OK.

However, Yii2 has good performance when providing such functions. I already have two projects based on Yii2, one of which has an average daily pv of around W, with no pressure at all. Many third-party tests also show that the performance of the Yii framework has always been at the top (yaf, phalcon, which is written in C, and the CI function is too simple. I think it is inappropriate to use it)

Of course, Yii2 is not a problem. One of the situations I have encountered is that components in some places have a high Coupling Degree, such as yii \ web \ User class, to maximize the development efficiency, he is a little coupled with ActiveRecord, which is of course no problem on the web. But now mobile development is a little unsuitable, you need to modify something yourself.

The other is that the framework itself lacks the support for data layering, and all things dealing with databases are ActiveRecord. The ActiveRecord provided by Yii2 is very easy to use and can easily lead to abuse. One of my projects has been abused in this way, and many similar codes$user = User::findOne($uid);I wrote it directly in the controller. After waking up, I spent a lot of time processing it.

Of course, the most annoying thing is the framework created by the web. From 1 to 2, there is no officially supported read/write splitting function.

Finally, Phalcon is definitely an artifact! Http://phalconphp.com

Laravel's core ideas are IoC and Facades. To implement these two ideas, a large number of abstract classes are required. If a framework is good or not, it seems that Laravel is still very elegant, although some _ call magic methods are used to implement Facades, this perfectly solves the coupling problem, I don't think it is very difficult to really understand the importance of decoupling without some experience in developing large websites. Therefore, business coupling is much more important than performance, in fact, the Code itself is not complex carefully to analyze a few core files you will suddenly open, recommend an article, say very fine http://www.yuansir-web.com /? P = 1012 & preview = true

I personally think there are two types of frameworks: one is pure MVC, and CI is a typical code. Many programmers write their own frameworks that are affected by CI, I am personally deeply influenced by CI, so the framework I write in my own project can basically be counted as the core detachment of CI, removing unnecessary compatibility and internationalization, however, after some large projects, I found that the existing MVC is far from meeting my business needs. Complicated Code leads to more and more layers of MVC, which are complicated and highly dependent, A lot of business splitting finds that MC has no way to split it, and the amount of work is huge. In the end, only the code is written more and more like a noodle, and the longer the pull

Recently, When I rewrite the framework myself, my View class had to be converted from static to normal class and instantiated using the new method, because only in this way can I use $ this in the template to point to the View class, to call some View functions in the template, such as request instance $ this-> request ()-> get ('user _ id'), and GET the $ _ get parameter user_id, however, in my original code, View: display ('index. php ') This call method won't work. In PHP5.5, there will be a warning that you use the static method to call non-static classes, but I don't want to use the new method. On the one hand, it is not elegant enough, on the other hand, it is not independent enough. If you want to use the View in the Controller, You need to inherit the View or assign a value to the Controller attribute after instantiation. In this way, the Controller is dependent, and I want it to be independent, when views are not used (in many cases, views are not required for API development), no View class is introduced. This problem is solved by Laravel's Facades.

Facades allows non-static calling in static mode. For details, refer to the Code's _ callStatic. The principle is very simple. Although it sacrifices some performance, I think it is worth it for elegance, then the most important thing is the combination of IoC and Facades. Why is Laravel able to use a large number of third-party framework code completely based on its advanced IoC idea, without any changes to third-party code, you can easily inject the code into the IoC container, and then organize and bind the code to Laravel. It looks like a patchwork of things. In fact, the core idea is like this. Every module is independent, just like building a building, all the accessories are independently produced and then combined. Only such coupling of the framework can be perfectly solved. Therefore, I write code very independently now, you do not need to use a function to directly Delete the corresponding files. The entire framework is not affected and still runs smoothly.

I have said a lot, but I want to say that many foreign frameworks are not without no reason. I need to learn to look at the essence of others' thoughts from a neutral perspective, it cannot be simply evaluated by programmers. This is also the essence of open source.

My project history: native PHP-> CodeIgniter-> Yii1-> Yii2

In July 12, 2014, Yii2 was in Beta stage, and Yii was not officially recommended for production environments. At the same time, I personally think it is not mature.

After one year of development, Yii2 is very mature by October 15, 2015, and my current project is developed based on Yii2 and has been applied to the production environment.

For details about how to develop and fix bugs, visit Github and the official website.

Currently, some documents are incomplete, suchDevelopment ToolsModule, guide document

How about swoole? Http://www.swoole.com/

Laravel I have tried to write a DEMO, which is not as easy as I think. I personally think that CI is enough for small projects. I 'd better use Symfony2 for big projects!

I currently think yaf + composer is quite nice.

I am studying laravel. It is better than thinkphp and zend framework 2. I think it is elegant when I look at routing.

CI is the framework of the PHP5.2 and 5.3 era.

Lavarel is the framework of the PHP5.4 era. If the documents are incomplete, do you mean L3 or L4? In addition, most documents can be found in posts on official forums. Documents are common indexes, and there are not many examples. Which open-source project is not like this? L4 documents are good.
Of course, Chinese documents cannot keep up.

When larave is used, in addition to the excellent code and interface design, the performance of the router is very poor!

So many frameworks ~ None of them have been used. ThinkPhp, yii, and so on. I don't know what it is.

I personally think Laravel has too many dependencies on third-party packages (especially Symfony). It gives people the feeling that it is a secondary development of Symfony.

The Laravel API documentation is also simplified. It is so streamlined that you don't know how to use the source code.

Laravel5.1 is an empty project or a database linked to show several records of a table:
Use AB-t 10-c 10 http: // 127.0.0.1/laravel511/public/index. php
Or AB-n100-c100 http: // 127.0.0.1/laravel511/public/index. php
Result request per time: <50

If you change to slim3 or ci3 for testing, you can achieve reququest per time: 200-300.

If you do not use any framework and perform the same test, the value can reach: request per time: 1300.

Do you still need to use the framework in this case? The Architecture of the project can be so low.

The machine hardware is blind.

CakePhP, relatively stable,

Why not use 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.