Discussion on community PHP Business Development _php Tutorial

Source: Internet
Author: User
In the current rapid development of the Internet business, new products such as springing up, the old product line new business is also constantly breaking and trying. This puts a higher demand on the rapid development iterations.

First, the basic operating environment
For the development of new products, we must be able to quickly set up a lamp architecture. Then there is nothing to choose a webserver, choose a php version, choose a MySQL version, then select a PHP development framework and select some common PHP extensions and base libraries. The reader may think that this process is fast, can it be faster?

The process of choice requires research and development students to the relevant technical direction has a certain accumulation, the pros and cons and priority, but also a research and learning. If you have one-click Installer, provide automated installation webserver,php,mysql, and carry a high-performance flexible PHP development framework, and provide standardized, secure, commonly used configuration files, can greatly shorten the cost of product line lamp system Research, shorten the work cycle.

One-click installation Four steps: (1) Download, (2) A small amount of configuration, (3) make install, (4) Start; (Of course, end, simple Ops tool), run the environment OK.

Ii. framework of Business development
Community product lines are fragmented and closed to develop their own business logic. In fact, there are a lot of common business logic processing between each product line, such as session verification, authority judgment, parameter verification, log printing, etc. Different product lines, all requests need to do these processing, can not repeat development? There are a lot of different business logic in wireless business development and PC, but there is also a lot of commonality between different product lines. Can you not repeat the development?

The product line is often abstracted internally for the processing of these general-purpose logic, either in the form of actionchain or through a base class scheme. The framework will be more thorough: the general logic that all these requests are processed is provided in the form of a business logic framework, and the development students only need to focus on the user's request for proprietary logic processing.

The processing logic for a user request, such as the blue part is the Controller framework processing flow, the green section and the controller framework, which handle all common business logic requests. And the person who really needs to develop the attention and development of the user request proprietary business processing, that is, the yellow part (of course, a not just an action script, a request processing will be horizontal MVC layered, this piece of follow-up will be involved. )

Business logic framework inheritance is provided in a one-click Installer and is simple to obtain.

Native PHP business and template coupling is very deep, did not do any layered design, the result is the code reusability is poor. Such a primitive PHP system is now almost extinct. The PHP development Framework unifies the process of routing, rendering, AutoLoad, abstraction of general business logic and abstraction of Base library, and proprietary business MVC layering, which has greatly accelerated the development of product line business logic. As shown in the following:

From the top down, is the access layer (high performance webserver), PHP development Framework (routing, automatic loading, view engine, etc.), application and base library, storage engine.

Iii. General Services
There are many common needs in the community product line, such as log processing, configuration file processing, string processing, database interaction, network interaction and so on. These algorithms and tools encapsulated into Phplib are more mature for product line use.

Community product line business functions exist a lot of commonality, such as comment function, tag function, friend function, Atlas, task system, etc., in many community product lines have similar new features and new requirements, each design and development?

These requirements have individual requirements on the UI of each product line, but the backend implementation is similar and has a certain commonality. Functional service, providing API interface to different product lines, product line only need to focus on the presentation of logic and private data processing logic, and service unified operation and maintenance, reduce the system complexity of the product.

Four, vertical split sub-system
So with the expansion of our business, the number of UI and module in a single application is increasing, and action and logic (corresponding to the M-layer in MVC, which can be further layered, this time not detailed), the interaction between logic and logic becomes more and more complex. Development students need to understand the logic of the entire application, a logic upgrade, need to troubleshoot the entire application under the existence of other UI or logic of the reverse dependency. Under the requirement of rapid development, the carding of the mutual coupling between logic is unclear, which will cause more and more problems, affect the quality of the project, and make it difficult to start the development.

The problem of a single system is exposed more and more, it is time to split the system. How to disassemble? Split vertically by business logic. Separate the functions of the business logic into independent subsystems. This time also need to consider the commonality of business, whether it can be serviced? Apply a generic service that already has the same requirements? At this point, the general business logic is encapsulated into a generic service or use a generic service, and the bypass business logic is independent subsystem, so that the original single huge system to do a lot of offloading. After this phase of refactoring is complete, the system join becomes as follows:

A single system is split into multiple apps (the app still has a horizontal MVC hierarchy) and has a large number of common services to reuse. As a result, the development team has been greatly improved in the concurrent development of the Division of labor.

V. Cross-system call framework
The real situation, however, does not completely eliminate dependencies between the split subsystems. In order to solve the relationship of data dependence among multiple subsystems, a unified solution is needed: API framework. Subsystems become standalone applications (apps), and apps have data dependencies that are available externally in the form of APIs. Such as:

When APP1 relies on APP2 or APP3 data, APP2 and APP3 provide a portion of the data interface as an API, and the data is packaged in a uniform manner, providing other app calls within the product line via the standard canonical URL. This form is very similar to a product opening API (for third-party open APIs, which we call Openapi, adhere to a unified protocol, and have the necessary authorization validation), while the API interface to resolve data dependencies between internal subsystems can be further simplified.

The API solution provided by the app provides an interface description (input, output), and a forwarding implementation of the url,logic that handles the API. Api_lib Unified to manage all API interfaces and provide a unified Api_server::call interface for invocation. Completely on the inside of the shield to the forwarding and implementation details. In order to achieve the simplification and unification of operation and maintenance in the product line, all subsystems are deployed on the same machine, and the API interface will bring additional network consumption and increase the QPS. In this deployment, the implementation of Api_server can be implemented by HTTP calls or optimizations for direct phprequire. Advantage:

(1) Frame unification, interface convergence, business decoupling;

(2) Performance improvement, high ease of use, high scalability;

Vi. UI Split Model
At this point, the independent subsystem can focus on its business logic, and the core system is also to relieve the burden. However, the core system Upgrade Update frequency is the highest, the business logic is also the most complex. At a certain time, the core system becomes bloated and difficult to maintain. There are some design patterns that can be used to reduce the scalability and maintainability of the program. But even so, there is a certain amount of learning costs, in an app, the development of students more or less need to focus on the code of other modules, gradually developed to upgrade a bit of the need to troubleshoot a lot of points. It is time to further relieve the burden. If you lighten the burden? Divided into two parts:

First step: Async model

Page rendering is divided into two stages: Theme page data and other non-themed page data. Data is provided by different data sources depending on the different parts of the page. Press this logic to further divide the app vertically.

Phpservice is a thin UI of phpmodule+ that returns formatted data.

Step Two: Synchronize the model

module do split, different business logic split into different module, divided into multiple data sources, respectively, to provide different data content, by the unified UI scheduling different data sources, unified rendering page return response.

With such continual burden, the subsystems and modules within the product line will be more and more, and need to maintain the unification of deployment and operation. The division of the team is very thin, the business understanding is focused and in-depth, cooperation, parallel efficiency will be higher, so as to shorten the entire development cycle.

Vii. Summary
As the business logic grows, the business functions of each subsystem or module are too bloated to be kept in a manageable scale. With the development of products, the subsystems and modules within the product line will be more and more, and need to maintain the unification of deployment and operation, and keep it simple. The division of the team is more granular, the business understanding remains focused and in-depth, cooperation, parallel efficiency will be higher, so that the entire development cycle is shortened.

by Luhaixia

http://www.bkjia.com/PHPjc/485978.html www.bkjia.com true http://www.bkjia.com/PHPjc/485978.html techarticle in the current rapid development of the Internet business, new products such as springing up, the old product line new business is also constantly breaking and trying. This presents a higher level of rapid development iterations ...

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