PHP Tutorials: PHP Framework Discussion

Source: Internet
Author: User
Tags copy http request php and php framework resource

I have been doing ror for a year, and I feel very good. Cooperate with agile practice (except pair, because it is remote cooperation with American engineers.) The development speed is indeed fast. A total of three people write code, a short six months, the project is basically over ....

Now that the new project is coming, customers are hard to choose between PHP and rails. I also intend to take this opportunity to learn about PHP.
Because the project customization is still relatively high, want to pass mature CMS and other systems to change the estimate is not.
It feels too slow to develop from scratch. So I want to start with the open source framework.

After understanding to find that some of the new PHP framework is basically exclusively learning (or plagiarism, especially cake, it is simply copy too much.) Rails. And these frameworks are well developed and increasingly popular with the PHP community. For example, foreign cake, domestic fleaphp, qeephp and so on, do not enumerate.

Yesterday with cake made a simple demo, really copy rails that is copied quite straightforward. Even rake has something to replace. I didn't find anything except migration and filter. Let me a person who does not know PHP, can still quickly get started.

On the one hand exclamation PHP copy Rails This thorough, on the other hand also lamented that these plagiarism does also bring the development of PHP efficiency. Although due to the reasons of PHP itself, the introduction of the framework to the performance of the impact is relatively large. But the emergence of these frameworks has greatly restructured the PHP community. (At least customers tell us to use rails as a cake, so they don't introduce more risk.) They also introduced some of their American teams back from rails.

I was wondering, and I thought rails was going to the market for PHP ... Now it feels like rails is saving php ...

Do we think that we should continue to convince our clients? Or do you use a cottage rails?

Master Robbin's reply:

There is an essential difference between PHP and Python/ruby's operating mechanism: PHP initializes all resources (such as creating a database link, loading a system class library, creating a cache, and so on) every time an HTTP request comes in, and it's not like python/ Like Ruby, a scripting language with a GC, Python/ruby initializes the resource when it is first started, and subsequent requests do not have to initialize the resource again.

The difference between this mechanism is that:

1, PHP is extremely difficult to have a serious memory leak problem, any code you write a rotten, anyway, every request one execution completed, all resources release light. Python/ruby, however, relies on a GC to reclaim memory, so a bit of carelessness may result in a memory leak problem that the GC cannot release.

2, PHP each request to initialize resources, this overhead is very large. So while the PHP parser itself is running very fast, once the complex PHP framework is used, the performance drop is very high because of the need to initialize the entire framework each time you request it, and the result of a very complex PHP framework is that the overall performance is far removed by Ruby. This is one of the reasons why the PHP community has been less inclined to use the framework for so many years.

3, because of PHP, each request to initialize the resource mechanism, but also caused the PHP to add a cross request of the advanced features is very difficult, this is the PHP itself a very large limit, but on the other hand, it is this restriction so that PHP is always maintained in a relatively simple web language, And that's why PHP became the first web programming language on the Internet, so it's not necessarily bad.

In short, PHP and ruby differences are still very large, not suitable for comparison, in fact, should be compared to Ruby and Python.

So I think that the way rails is framed by PHP is actually putting PHP in the wrong direction, so it's better that rails is misleading PHP. By the way: DHH before writing Basecamp, has been using PHP, and also wrote a PHP rapid development framework, he switched to Ruby later, the original PHP framework was also transplanted, the framework is actually the original rails prototype. So why did DHH not do rails directly based on PHP? Do you want to switch to Ruby before publishing rails? You see PHP This kind of operation mechanism to know, PHP makes the complex web development framework is not a bright road.

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: 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.