Use flexible system structures in PHP

Source: Internet
Author: User
I wanted to write this article a long time ago, but I never had time. I don't want to tell you how to do it here. I hope you can take a look at it and discuss with you how to develop a good and scalable web application. I am engaged in development

I wanted to write this article a long time ago, but I never had time. I don't want to tell you how to do it here. I hope you can take a look at it and discuss with you how to develop a good and scalable web application.

I have been engaged in development for two or three years. I did not trust my first program and wrote it myself. now my web development skills have been greatly improved, for example, sourceForge http://sourceforge.net/) is a more mature work, the code is divided into various classes and functions. The database structure is also clear. Different parts of the site are independent from other parts.

However, this site is not perfect. If I have to write it again, I will use the object or function library method to make the HTML layer and the database layer more explicit.

I have invented many managers who love to use charts to express their ideas. here I also provide one. The idea of such a system is to separate your logic from the surface, which means that anything complicated will be put down on the API/data access layer ".

For security check, update, and other code, you 'd better not put it in the HTML layer. you should put the theoretical code in the API layer. The HTML layer only calls simple functions and returns arrays, objects, or favorite database result sets.

In this figure, the HTML interface either calls the API layer directly or calls an HTML tool library (for example, a pop-up window is generated ), those databases can be called through a database abstraction layer (so that you do not have to bind them to a database ).

Basic Points
For a flexible system, there are the following basic points:
1. Independent database
2. Independent presentation layer
3. Easy to fix
4. Object-oriented or at least split into function libraries for calling
I have come up with these things. apart from the above mentioned, you can also discuss other things in the forum.

Let's discuss the above points in detail as follows:

1. Independent database
During the design, you may not know how cumbersome your site is. remember that you cannot bind it to a lightweight database, such as MS Access or others. Therefore, you should consider scalability. if you change the database, you do not need to make too many corrections, or even do not need to make any corrections. this is the most fantasy.

When using PHP, function calls for various databases are different. you need to perform different encoding for the database of the application. To change this situation, you can apply a database abstraction layer, such as a database developed by PHPLib or others.

2. Independent presentation layer
If you want to develop a truly ambitious and complex application, you must begin to consider the database interface title, so that you can do less copy and paste work. For example, you need to make your site WAP-effective so that mobile phone users can visit it. If your utilization is well designed, you only need to write a lightweight WAP presentation layer to call all your database access objects. However, if your exploitation system is poorly designed, you may need to write a new one, so that you need to protect both an HTML version and a WAP version.

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.