Read the Laravel source code thoughts

Source: Internet
Author: User
Since the company has been using the YAF framework, at least a number of projects are based on the YAF framework. I believe all the friends who have used YAF can clearly feel that the function of YAF is too concise, basically provide an MVC mode, an automatic loading mechanism, a routing mechanism, the rest of the basic nothing.

Of course, as a C language framework, do not ask for it, and after all, is a person to maintain, people's time is limited, and brother Bird has been in the maintenance of his YAF framework, once again express heartfelt thanks. So, in line with the unified requirements, so decided to take a closer look at the main mainstream framework of the specific implementation, and then pull something out of the inside to let themselves use.

The first thought of the framework is laravel, not only because it is a more elegant framework, not only because it has an ultra-high market share, but also from its function and performance, have a relatively superior performance, but has not been carefully studied its source code, have to say is a loss.

To study a framework, it is important to study the implementation of its various mechanisms of the process, for its helper functions, pour in the second, after all, we write these libraries are not inefficient.

All right, don't talk nonsense. Today is just about half an hour or so of the implementation of the DB layer, and I also made appropriate changes to it, such as its database under the query there are two folders, we directly put it into a folder, and we also based on its automatic loading method is renamed, For example, connection will be renamed to Dbx_query_connect, and friends who may be familiar with YAF and Laravel will know that I have created a DBX directory under the library, and then there is a Query subdirectory. Then there's the connect.php file.

But the deepest feeling is that its jump really bad, is a simple $conn->table ("T_admin")->get (); There are no more than 20 jumps, the core is three places, one is builder, one is processor, One is grammar, of course, and we find that there is also an arr, which is the arr.php file in the source code's support directory, and it is called a method. In general, the execution of a query, five to 10 times the jump, this complexity we are all loved, and usually we generally do so. But 10 times to 20 times the jump, it will make people thinking is not clear, also decided to want to more skilled to harness it, or it takes a lot of kung Fu.

By the way, here I look at the code version is 5.1.4, and then I will be a series of reading source code information, one is because of the needs of the work, the second is itself more interested in, like friends can continue to pay attention to the next Olympics.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

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