Mvc-laravel vs CakePHP vs CodeIgniter views (performance, development efficiency, debt capacity)

Source: Internet
Author: User
Tags codeigniter zend framework

Reply content:

Recently intended to be a more medium-sized PHP application, think of a broader MVC framework than the application.

Requirements

1. Support for namespaces 

2. Does not support PHP4

3. Architecture, performance is more important 

4. Long-term stability, not a framework that will soon be eliminated or disbanded

Yii2, Symfony2 are too large, not suitable. Taking into account the Laravel CakePHP Kohana CI.


Let's start by saying what you think about these three frameworks.

1) CI 2.x official website Abandoning state CI framework is too light, many things have to be done by themselves, very old CI framework can not track code in IDE, click class name can not jump past 

2) CakePHP 2.x Why Backward compatible with PHP4? You have to use a crappy App::use() instead of namespace! In order to be compatible with PHP4, the whole architecture is messy. If CakePHP gives up compatibility with PHP4, there should be more people to use it. 

3) Laravel does not support php4, and supports a lot of praise on the namespace. Look carefully at each review article. It feels like a gunman.


On-line including Segmentfault on the framework of the comparison, but is basically a copy of the reproduced, rather than their own use of the real experience, look forward to the use of the real experience, rather than copying and pasting online conformity assessment.

Today, using Laravel, I found that the documentation is not as rich as the official promotion, but less and less clear. There are those methods for Route that can't be found at all. The official documentation is just a few simple examples that are not exhaustive at all.


<code>Larvel is used today and found that the documentation is not as rich as the official promotion, but less unclear.

There are those methods for Route that can't be found at all. The official documentation is just a few simple examples that are not exhaustive at all.

 

</code>


2015-6-16 Supplement:

Back to this question again, I have been using CodeIgniter, thinkphp and Yii2 to develop some complete projects. Now found that the PHP MVC pattern is really difficult to meet the demand, to later component, now to laravel ideas, difficult to understand, always feel in pursuit, particularly tired.

In fact, in the beginning, I went through too many detours, many years ago, for OOP have a strong rejection and extreme resistance, the reason is that the use of class will cause the program to run very slowly, the fundamental is that I use the operating environment is too rotten, virtual host is not as good, and still win. By the later MVC pattern, the number of files loaded was almost unmatched. Later began to use the MVC framework, the normal host has been completely unable to support, most of the virtual host is the majority of the win server, and PHP up to PHP5.3 is good, there are a lot of incredibly still in the PHP5.0 (virtual host is only to provide an FTP user name password type).

Through too many detours, has always been the hardware conditions, operating environment bound thinking.


CakePHP did not use it for comment.

A PHP Programmer's growth process can often be likened to CI-----Laravel ci. CI and laravel are basically considered to be the most used frameworks of PHP framework hegemony in the past years and now two times. CI is perfect for novice and master, and Laravel is suitable for mid-level programmers to improve productivity.


Detailed

CI offers less of what is the most important reason for its invincibility.
In addition, CI's documentation is simply a model of open source software, very clear and detailed!

It can give us the core of the function, let us really feel the essence of PHP to do the web, to experience the true charm of MVC. BTW, do not underestimate MVC, it as a modern GUI software development of the most popular structure, not in the use of MVC time to see the two-eye description can understand, we need to do, to feel.

Laravel claims to completely imitate rails and has to admit that they did, including performance. ^_^ Laravel In fact is in line with the development characteristics of Internet products: quickly make available products, and then high-speed iteration.

If you use Laravel, you don't have to worry about performance issues, because performance is not a problem when it comes to performance issues. Have the user have the time, want how to reconstruct how to reconstruct, the complete ~


A lot of your analysis is wrong.

(1) Ellislab did want to find someone to get a CI, but in fact, the update of CI on GitHub has not stopped.

(2) CakePHP 2.x only support PHP 5.x, does not support PHP 4.x, support PHP 4.x is cakephp 1.x, CakePHP 2.x no namespace is because the namespace is PHP 5.3, and the original PHP Community plan is to put these features to P HP 6 miles. The only version that supports PHP 5.4 is cakephp 3, which is now ready for the official version. If you prefer long-term stability, cakephp is definitely the first choice, and it is still maintaining the PHP 4.x only version of CakePHP 1.x bug fixes.

(3) If you think Yii2 and Symfony are big, laravel you should not consider, this thing is built on a lot of symfony components, but the size really so important? It's not the age of 1MB space 1~2RMB more than 10 years ago, is it?

July 20 Update: The latest YII2 has natively supported read-write separations, supporting a write database and multiple slave databases. also supports multiple write libraries from multiple libraries!

Do not agree with the title of the main Yii2 on the large, laravel count his reliance on the third-party code, more than Yii2 file. Moreover, it is very superficial to judge whether a framework is large or not only from a single document.

In fact, the YII2 itself is very flexible and most of the components can be replaced. You can read their latest documents, YII2 itself can be embedded in your original code, you want to use AR to load AR components (in fact, this function in the YII1 era, I was in the original project very easy to use the YII1 model components, But because the previous structure was too confusing and some other reason, the project was eventually abandoned.

YII2 itself is fully functional, and has been actively absorbing other framework excellent features, such as Symfony2 Assetbundle, webdebug are very useful functions. Then is the background artifact Gii+gridview These two components, to cope with most background development is simple point two, change is OK, and dataprovider This component is also very practical. In short, most of the web development to use the functionality of Yii to help you provide a ready-made, you only need to use the good, not easy to inherit a change, and then in the configuration to replace him is OK.

However, in the premise of providing such versatility, Yii2 performance is not bad, I have two projects are based on YII2, one of the daily average PV at about 300W, completely pressure-free. Many third-party tests also show that the performance of YII framework has always been the top (YAF, Phalcon these in C write the other forget, CI function is too simple, I think it is not appropriate to take him)

Of course, YII2 is not no problem, for the moment I met a situation is some local components of the coupling degree is a bit high, such as Yii\web\user this class, he to maximize the development efficiency, with activerecord coupling a bit high, on the web this of course no problem, But now mobile development, this is a bit inappropriate, you need to change something.

The other is that the framework itself lacks the support of data layering, and everything that deals with databases is ActiveRecord. And because YII2 provides activerecord very easy to use, it is easy to lead to abuse, one of my projects is this abuse, many similar code$user = User::findOne($uid);directly written in the controller, wake up to spend a lot of time to deal with.

Of course, the deepest resentment is called the web2.0 of the framework, incredibly from 1 to 2 have no official support of the read and write separation function, this is not justified.

The last Phalcon is definitely an artifact! Http://phalconphp.com

Laravel's core idea is IOC and facades, to achieve these two ideas will inevitably require a large number of abstract classes, a framework is not good to synthesize, the overall look laravel is very elegant, although in order to achieve facades use some __call magic method, But this is very perfect to solve the coupling problem, I think there is no certain large web site development experience is difficult to truly understand the importance of decoupling, so compared to performance, business coupling degree is much more important, in fact, the code itself is not complex carefully analyze several core files you will suddenly enlightened, recommend an article, said very fine HTTP ://www.yuansir-web.com/?p=1012&preview=true

I personally feel that there are two main frameworks now, one is pure mvc, CI is a typical code, many programmers write their own framework is affected by the CI, I personally is deeply affected by CI, so in their own projects within the framework can basically be classified as the core of CI stripping, Removed the unwanted compatibility and internationalization parts, but after some large projects, I found that the existing MVC is far from meeting my business needs, complex code leads to more and more MVC three layers of complexity, rely on serious, a lot of business split when found that MC has no way to open , the amount of work, and finally only the code is more and more like noodles, more and more long

When I recently rewrote the framework, my view class had to be converted from static to normal and instantiated with new, because only then would I be able to use $this in the template to point to the view class and invoke some view function functions in the template, such as the request instance $ This->request ()->get (' user_id '), gets the $_get parameter user_id, but if you do this I have the original code inside view::d isplay (' index.php ') such a call method is not, There will be a warning in PHP5.5 that you use static methods to invoke non-static classes, but I do not want to use the new way, on the one hand is not elegant, on the other hand is not enough independence, if you need to use view in the controller to inherit or instantiate a property to be assigned to the controller, this depends on the , I want the controller to be independent, without the need to introduce the view class when the view is not used (in many cases API development does not require a view), and this problem is exactly what laravel facades solves.

Facades allows static calls to non-static fatigue, in particular, can see the code of __callstatic, the principle is very simple, although this sacrifices some performance, but for this elegance I think it is worthwhile, then the most important is the IOC and facades of the Union, Why Laravel and use a large number of third-party framework code, completely based on its advanced IOC ideas, without how to change the third-party code can be easily injected into the IOC container, and then the organization bound to the Laravel, looks like patchwork, in fact, the core idea is this, Any module is independent, as if the building, all the accessories are independent production, and then combined together, only so that the framework of the coupling is perfectly solved, so I now write code will be particularly independent, do not need to use a function, directly delete the corresponding file, the entire framework is not affected by any impact, still smooth execution


Said a lot, in fact, the main reason is to say that many foreign frameworks fire is not without reason, to learn from the neutral angle to look at the essence of others, not from the programmer's simple assessment of a denial, which is the essence of open source, set thinking broad

My project history: native Php->codeigniter->yii1->yii2

July 12, 2014 that meeting, YII2 in the beta period, YII officials are not recommended for the production environment, but also the individual is not considered mature.

After a year of development, as of October 15, 2015, YII2 has been very mature, and my current project is based on the development of YII2, has been applied to the production environment.

Specific development, repair bug history, you can see GitHub and official website

Currently, some documents are not sound, such asDevelopment Toolsmodules, guide documents

How about Swoole? http://www.swoole.com/

Laravel I tried to write a demo, and did not imagine so easy to use, I think small projects with CI enough, the big one or use Symfony2 bar!

I think Yaf+composer's pretty cool right now.

is learning Laravel, more than the thinkphp and Zend Framework 2 is cool, light look at the route to feel elegant.


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

Lavarel is the framework of the PHP5.4 era, the document is not all you mean L3 or L4? And most of the documents can be found in the official forum posts, the document is a normal index, not too many examples are normal, which open source project is not the case. L4 the documentation is good.

Of course, the Chinese document must not keep up.

Used Larave, in addition to his code written very good, interface design is very beautiful, router performance is very poor!

So many frames ~ one is useless. thinkphp experience, Yii also experienced, specifically how, I do not know

I personally think that Laravel to third-party package is too much to rely on (especially symfony), the feeling is to symfony two times development

The Laravel API documentation is too streamlined. Streamlined so that you do not see the source code do not know how to use.

laravel5.1 an empty project, or a linked database, takes a few records of a table to show:

With Ab-t 10-c http://127.0.0.1/laravel511/public/index.php
or ab-n100-c100 http://127.0.0.1/laravel511/public/index.php
Results from request per time: <50

And if you change slim3 or CI3 test, you can reach Reququest per time:200-300

If no frame is used, the same test can be achieved: request per time:1300

Do not understand such a situation, but also to use the framework, the project on the framework of the case can be so low ah.

Bright white blind machine hardware AH.

CakePhP, more stable,


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