Home  >  Article  >  Backend Development  >  Three Worlds in PHP Development_PHP Tutorial

Three Worlds in PHP Development_PHP Tutorial

WBOY
WBOYOriginal
2016-07-15 13:23:40688browse

There are a lot of discussions about the PHP framework now. I think there are two main problems here: First, blind worship of the framework, thinking that the only way to adopt framework design is to be orthodox. Otherwise, you are not in the mainstream and you are a rookie. Secondly, there are heavy traces of imitating Java. I'm not saying that imitation is a bad thing. What I mean here is some "imitation" blindly carried out without careful thought, without considering the principles and purposes of the framework or certain designs, the actual situation of the project being undertaken, and the similarities and differences between Java and PHP. "Work. The article "Three Worlds in PHP Development" is an article written based on the "actual situation of the project", focusing on discussing some characteristics of PHP development in different development fields. If there is anything inappropriate, please correct me.

In the field of PHP development, there are constant discussions about OO, frameworks, design patterns, MVC models, and the various benefits these bring. I don't deny these benefits, I just think that you can't blindly follow a certain development method. All methods have their scope of application, and PHP development is no exception. PHP development can be roughly divided into three different development areas based on audience, service goals, etc.: industry commercial software, general shareware, and private dedicated software. In these different fields, the main development methods used are also different. It is necessary to clarify the field of your product and determine a development method. It should be noted that strictly speaking, these three categories are not completely parallel, and they are clearly distinct. I hope this will not cause trouble to everyone, and you can just understand the meaning. :)

Limited to my personal level and narrow viewpoints, some opinions are inevitably biased or even extreme. I hope the Fang family will give you some advice.

First, let’s talk about industry commercial software:

This type of software is mainly aimed at certain applications in specific industries or enterprises, and the project design is relatively complex. It is generally undertaken independently by a certain development company, with almost no competitors. At present, it is mainly represented by CRM, CMS, OA, etc. Customers of this type of software do not care about how fast the system runs, but whether the system can coordinate to complete the required functions. Because it is for specific customers, this type of software has a relatively narrow scope of use. If it is changed to another customer, it usually cannot run well (the operation here does not refer to the execution of the code, but to the realization of the function), and it must be dismantled. Start over. In order to reduce the unnecessary duplication of basic work in developing different systems, we must extract the same parts of these different system applications. These identical parts contain both technical similarities in the code and similarities in the design process. This is a process of abstracting a problem. Our current frameworks and models are the fruits of our predecessors’ labor in these abstract processes. Since almost every Java project is usually a relatively large and complex application, we can see frameworks and patterns everywhere in these projects. If you don't adopt this development approach, it's almost impossible to move forward. PHP is very similar to Java when developing such applications. The only difference is that their respective running environments (mainly referring to their respective language interpreters, the same below) are different. PHP is a scripting language that comes at a heavy cost to support various OO language features. Both in space and time. Fortunately, for this type of industry, the performance of commercial software is secondary, and you can decide the operating environment yourself, so using PHP5, which has good support for OO features, is an inevitable choice. And using some frameworks is also necessary.

Let’s talk about universal shareware:

This concept comes from the concept of traditional desktop shareware. Its main feature is that there are many customers (including potential customers) and the same type of software Users also have more choices and competition is fiercer. This type of software is currently represented by forum community programs. In order to win customers, you must do better than your average competitors. For this type of software, competition mainly lies in the following aspects:

1. Interface

The interface is the response of your customers (including your customers’ customers) to your product first impression. Therefore the interface must be friendly. Interface not only refers to appearance, but also includes operability. The interface must take into account the habits of most people, and the operation must be simple and smooth. Although the appearance is radish and cabbage, you must also leave an option (interface) to the customer so that the customer can modify and use it very conveniently.

2. Performance

A good interface will certainly add points to your product. But in this world where Ctrl+C and Ctrl+V are available, no matter how excellent the interface is, it will be "learned" by competitors in an instant. If the interface is the first impression, then performance will be the fatal test. Because the interface can be replaced, but you can't expect customers to improve the code themselves. In PHP development, performance largely refers to the running speed of the code. Another important manifestation is the consumption of system resources. The lower the resource occupancy of each processing process, the more time the system has to handle more requests simultaneously. These are all subtleties that reveal the true meaning. I hope to have the opportunity to discuss this in detail with you again. But one of my personal general principles is to avoid using classes. Classes in PHP are really performance killers. A direct consequence of avoiding classes is avoiding frameworks. Some people say that doing so will affect development efficiency. I admit that it may have some such effects. But I think there are two types of efficiency: development efficiency and operational efficiency. It is inappropriate for us to do this in industry commercial software, but in general shareware, we have many competitors. Moreover, customers don’t care what framework you use or what model you adopt. Customers only care about their own experience. You can't have it both ways. We must give up some development efficiency to ensure operational efficiency. This is also a last resort.

3. Compatibility

The compatibility here mainly refers to the compatibility of code between different PHP versions. We've noticed that generally, newer PHP versions mean better performance and stability. Therefore, we should use the functions and syntax of the new version as much as possible. But on the other hand, due to the large number of users, we cannot make assumptions about each user's operating environment. Not every customer has an independent server. Many customers who use general-purpose shared software use virtual hosts as their running platforms. Moreover, not every web hosting provider can support the latest version of the PHP interpreter. Another side effect of compatibility is that it limits some development methods. There is no doubt that it is very difficult to use various OO features and techniques on the PHP4 platform. There is a question of balance. How to deal with this balance, I think some surveys on the distribution of running PHP versions may be a powerful reference.

Finally, there is proprietary software.

Private special software refers to an application system independently developed by a company with certain R&D capabilities based on its own business characteristics. For personal use only and rarely sold as a product. The complexity of this type of system is no less than that of enterprise commercial software, but its performance requirements are even higher and almost demanding. These systems are represented by Sina's news release system and Taobao's item buying and selling management (although not all of these are developed using PHP). The characteristic of this type of system is that the enterprise usually has its own independent server, which can be configured and optimized in a targeted manner. If you want to deal with these applications, you must start from the characteristics of the enterprise's business and specifically optimize and compile the PHP module according to the actual server conditions. Then PHP extensions or even Zend extensions are used to implement some functions instead of scripts. This requires PHP programmers to also have certain knowledge of C language (although other languages ​​are theoretically possible, there is no doubt that C is the safest and most convenient).

(Editor-in-charge Huo Fenghuang

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446828.htmlTechArticleThere is a lot of discussion about the PHP framework now. I think there are two main problems here: first, blind worship of the framework; I think that using framework design is the only way to be orthodox, otherwise you will be inferior and a rookie...
Statement:
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