Home > Backend Development > PHP Tutorial > If a PHPer who is about to advance wants to read through the source code of an open source project, which one should he study better?

If a PHPer who is about to advance wants to read through the source code of an open source project, which one should he study better?

WBOY
Release: 2016-10-17 09:13:03
Original
1159 people have browsed it

Reply content:

In fact, reading the PHP source code should help the most. The prerequisite is to have some basic knowledge of operating systems and c languagephp-internals.com/ There is no project suitable for everyone. It is best to read the code that you find interesting. There are many Trending PHP repositories on GitHub this month · GitHub I think thinkphp is pretty good It is recommended that you read the work that our team has developed based on the framework.
Framework: zentaophp
Products: zentao, ranzhi, chanzhi
We hold different views on many frameworks on the market, so we developed our own framework and implemented a number of open source products based on this framework, each There are dozens of functional modules, multi-language support, in-depth extension mechanisms, API calling mechanisms, etc. If you are reading framework code to learn PHP, then I still recommend that you look at the more well-known frameworks, such as Symfony2, Lavavel, Yii2, but in fact, each framework is not so easy to understand the source code, and you need to add Knowledge of design patterns and new language features. The important thing is to learn the ideas inside rather than the language techniques. Based on the several open source frameworks you tagged, my personal opinions are as follows:

1. WP: It is not recommended to delve too much into it. This blog system is not bad to use, and it can also be used as a corporate website, but the design pattern used in the source code is quite special. Extensive use of global variables cannot be regarded as an advanced way. If you want to study strange tricks, you can take a look at this;
2. Discuz!: It has research value, and of course includes several other open source systems of the Discuz family. ucenter, uhome, etc., learning some of his multi-system integration architecture can provide you with many new ideas;
3. Yii: It is recommended to study it carefully, especially Yii2, both the directory structure and OOP design pattern are very worth learning. The disadvantage is that there is not much domestic information and it takes a while;
4. Symfony: It is not used much and cannot give objective opinions. The best research is to write code and do projects.
I suggest you get involved. Only with enough project experience can you distinguish between good and bad. If you don’t have enough experience, you can’t tell the difference between good and bad.
You can participate in my open source project
https://git .oschina.net/yiany/yiany Personally, I think there are two directions
  • One: the overall web architecture category
  • The second one: the business logic category

Let’s talk about the overall web architecture category first. The best products are the popular frameworks. I recommend Yii, Symfony, ZendFramework, This type of web development framework has a complete structure, tight encapsulation, and complete functions. When studying these frameworks, you will experience various concepts in the web.
For example, if you are studying Yii, you will find that Yii places cookie encapsulation on the request and response objects respectively. This will make it clearer to you that the cookie needs to be obtained from the browser during the request and the Set to the browser on response.
Moreover, in addition to concepts on the web, you can also learn good design solutions, design concepts, implementation strategies, etc. from excellent frameworks.
For another example, in Yii, if you need to reuse controller action code, you can use behavior to extend it, so that a common operation is injected into the controller. At this time, you can think that if there is a need to break the structure of functional reuse, you can choose to use the injection class technology to achieve it. Next, you will think, how is this class injection solution implemented? After tracing the code, you will find that the Traits mechanism in object-oriented is used. This expands the learning surface.
(PS: The reason for using Yii as an example is that some articles about Yii are being published recently, nothing else)


Let’s talk about business logic classes
The so-called business logic classes are those on the market that can implement certain functions products, such as ecshop, phpCMS, etc. The characteristic of this type of product is that the typical business logic has been implemented, and the implementation is very good. In this way, when you learn the code, you will also understand the typical business logic of a certain aspect and know what you are doing. time, what to do.
For example, if you are learning Ecshop, then you will know the business logic that a typical mall should have. When you encounter similar functions, you will get twice the result with half the effort.
(PS: There are many such products, you can look at the world, not just domestic, but the probability of you using domestic products later will be capitalized)

Any of the above products, be sure to choose one. Read and study, don’t spend a lot of time on making choices. As time goes by, your enthusiasm wanes, and you find that you haven’t officially started reading yet, but just finished making choices. That would be a pity!

Finally, it is strongly recommended to read the manual twice before talking about anything else, definitely! laravel bar Symfony uses a lot of design patterns commonly used in Java. If it is used for learning, I think it is more suitable for me, although many of the writing methods are relatively old and too complex.

Laravel is separated from symfony, and its writing method and technology are relatively new.

yaf and phalcon are the trends in practical applications. PHP+C takes into account both performance and development efficiency. It is also necessary to read some C code.
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template