It is not difficult to facilitate the problem of qualified PHP programmers (maybe just a problem that spends a long time), so the system analysis and design is particularly important. For a system analyst who serves as a PHP project, two problems are facing:
The PHP language itself is limited. This is especially significant in the object-oriented design of complex systems. Object-oriented properties of PHP have improved in existing versions, but it is not very sound, it is not enough to serve as an object-oriented design; even if the eye is long, in the upcoming PHP supported by Zend Engine 2.0 Of the object-oriented characteristics will not be like the popular Java or C (on this aspect, see another article I published in the DeveloperWorks China website). However, if you use a full-faced process (accurately the web page), you can imagine that the design of the entire system is very complicated, and the complexity and maintenance difficulties brought more difficult to cope. The existing information is seriously lacking. This is a well-known phenomenon that is in short supply for Web projects; in these limited materials, the design information on PHP is very scarce. If the company or I have no relevant technological accumulation, the system analyst can only explore the method in the dark (two cases, one is to move other items such as Java or C design, the second is to think that the project is simple and not negative Responsible herbs.).
Since the system faces, this is the case, how can I use the analysis and design of the PHP system properly? The initial idea should require a class of tasks to be divided into items:
Recommended projects involving a large number of customer itself or customer industries, including office systems, order systems, and other commercial systems. Simple website projects, including items that need to bear high visits or require quick response, such as brand websites or event sites, and other websites. Comprehensive website project. It usually contains multiple relatively independent subsystems such as the news subsystem, forum system, product display subsystem, etc.
The original intention of PHP is to solve the urgent needs of the two projects, and the language itself has made good transformations for these projects. Many PHP developers also have more or less experience in these projects, and the examples in related books are mostly around. Relatively speaking, there are not many information on the first system, and various publications have little mention of their content. Therefore, the first type of item will be described in detail herein (for the MVC mode and class package), and the second item (related to hack code) and the design method of the third item are included. Of course, these projects that are not classified can only be described in the ways described herein, and the system analyst needs to trade out all aspects of factors.
Solution 1: How to separate the user interface and the background operation involving a large number of commercial logic projects? How to avoid confusing business logic in general process control? As a rigorous commercial project, you need to consider a lot of similar problems. For such items that are taken by PHP, the design of the Model-View-Controller (MVC) mode is a very good way.
Theoretical description I don't want to explain more to explain the MVC mode itself - simple from literal and application, by dividing the system's design is divided into Model model / logic, the View view / interface, the Controller control / process three logical parts reaches good The project effect, with this convenience of the work of each developer and reduces the future maintenance cost. (If you are familiar with the MODEL 2 mode developed by JSP, it can be found to be a very good embodiment of the MVC mode.) For real project development, existing problems include web designers and procedures developers' work interleavers and conflicts and Business logic embedded pages can not be reused, it is difficult to maintain. Introducing the MVC mode on the one hand, the overall design of the system, is pointed out in the clear direction, and is also a good guidance for the division of labor of the development team.
Since the overall structure of the system is logically divided into three parts in accordance with the MVC mode, the developers of the team also have developers for each part. Developer Role Related System Logic Responsibilities Web Design VIEW View / Interface Design Web Template for All User Interfaces. Control Process Developer Controller Control / Process Writing All PHP Pages in the System Process. Business Logic Developers Model Model / Logic Development System Design Each class (which).
It can be seen from the above form that the traditional web design and procedures developed by the personnel have been broken, and the responsibility is based on system logic. For web designers, duties do not change, accurately, due to such division avoids the disputes between past and programming staff, they complete the web template, so simply pay attention to pure web code (mainly HTML, maybe there)) Other clients' code such as WML is not required to be ...?> Interference by the server. The programming staff is divided into two parts: which is easier to grasp is commercial logic developers, their tasks are completed according to the module given by the system analyst (accurately the class method), and PHP in their hands is more like The general programming language (such as Java) does not matter with the Web; it is more difficult to accept the control process developer. Their task is to call commercial logic according to the client's input while implementing system design. (The corresponding type of method) and the output update interface (handling the design web page template), in their hands, PHP can give full play to the advantage of the web programming language.
The concept of code organization related topics is some abstraction, and there is no instance of demonstration is difficult to accept. Before an example, let me introduce my recommended code structure for such projects:
First-level catalog secondary directory three-level directory note / project_name project source code root root / TEMPLATES page template catalog (View) / admin management console directory / Admin web page template / include business logical directory (model) / temp temporary code catalog (Optional), available for developers to test some test code test / images picture directory, web page template adopts / css style single directory, web page template adopts / Scripts client code directory, web template adopts / admin management console directory ( Select), including all bachels management function code / Other_dir corresponds to / other_dir under the root of the source code, including the function code / other_dir other with the class, such as the user-related / member directory or with From the product-related / product directory, etc. /config.inc.php global configuration variable, define global variables in the system / Security.inc.php Security Policy Control (optional) / error.php error control Back to page (optional) You can also use a static page such as / error.html or other page name.
After reading it, is you evoked to use Java's memories for web development? For example, the Classes directory and lib directory under the web-inf directory and the web.xml are rules for development - although the WEB server that supports PHP is not possible to automatically load files in these directories like the Java application server, it is specified for a suitable The code organization mode is still very conducive to development convenience and subsequent maintenance. (I started to consider the code structure of the PHP project is to be inspired by Tomcat's development manual.)
An example of a user login is based on the above code catalog, the implementation of the MVC mode described above can be explained in a simpler explanation. Take the most common user login function as an example. It envisaged that a / member directory in the / project_name directory contains everything about the user, which contains the user name and password used by the login.php page accepts the user's login. The index.php page is The user home page after the login is completed, and the error.php under the / project_name directory is the error display page after the login failed. The user requests to enter the user home page /me/index.php page through other parts of the system. At this time, the page determines that the user situation: the logged in user directly displays this page content (can be used to check the session, etc.); Log in (redirect to /me mal/login.php); an unknown error (redirection to /ERROR.PHP) has occurred. At the same time, the corresponding response is taken. If the user is guided to the login page ie /me/login.php page, the page accepts the user's login information (user name and password) and determines whether proper login: Correct login, redirect to the user home / member / index. PHP; login error is redirected to / error.php. If the user is guided to the error display page / error.php page (whether from which page is coming from above), the error message will be displayed.
The flow chart is as follows:
According to the above text description and illustration, combine the implementation of the MVC mode, it is very easy to write the frame code of these pages:
First look at the simple page / error.php: then /member/login.php: Finally /member/index.php:
(Note: The above code is just a piece, and there is no consideration of the project global, only demonstrations)
About Controller can first become, the above three page code is the above-mentioned Controller Control / Process Code. Obviously, their do not include a specific operation, there is no line of web code, and some are just the process control code consistent with the previous flowchart (looking away, the common feature of these pages is full of reference web templates and output, acquiring objects And execute some method or redirection).
Select one of the page / Member/Login.php, detailed explanation. The entire page is divided into two parts by judging whether the submission form is divided into two parts: display the login form for users to fill in and process login information. As the former directly references a member_login.dwt on the page template catalog / templates and outputs after parsing; as the latter first acquired a MEMBER object (this object is for commercial logical directory / include Member.inc.php under the commercial logic / include In the middle, then the result of the login judgment is obtained. In this control page, Member_Login.dwt appears as the View View / Interface, and class MEMBER acts as the Model model / logic, and the page code itself will be the Controller control / process. Below is the named /member/login.php frame code:
(About template class and application in MVC mode, you can refer to my article in developerWorks "in the PHP world to choose the most suitable template")
Since Model talked to Model, the following is another important topic: Application of class package in PHP project.
Note that the word "class package" - this is the essence of "object-oriented" or other other "object design" methods. "Class Package" only tells the way the business logic is encapsulated into various classes, so the "class" here is not therefore "class"-accurately, "" " Class "is actually the result of merged a series of related functional modules. Why don't you use this object-oriented approach to design the system? Does PHP have object-oriented features? Nice, PHP has such a property, but it is very incomplete (you can refer to my article in DeveloperWorks "from Zend Engine 2.0's Design Blueprint (Draft)"). For example, PHP is a concept and implementation method without an interface, and there is no multi-inheritance, a typical object-oriented characteristic such as overloading. If you do not use object-oriented design methods, you may be very easy to design the design phase, but the detailed design phase will be more depressed, and if you still have to stick to the coding stage, it is hard to say. On the other hand, if it is not introduced into the concept of the class, it is used to implement the module function, so it is possible to imagine how much functions will be used in a "pure" medium large system, which is very troublesome. obvious.
Or return to the PHP language itself. Although PHP does not provide any actual object-oriented support, it is also provided to definitions of classes and their properties and methods. So naturally, it is possible to use classes to encapsulate correlation function modules, which can borrow some of the advantages of some object design, and avoid some of the disadvantages of the function module.
(Some systems using the function module will use a way: write related functions in the same file, which can be introduced into a separate file when referenced. This file contains all the user related to the user. Operation, you can request this file before processing the user login, then call functions such as member_login (). But this way only solves the code organization problem in the system in the system, and does not solve the problem of name conflict. It will be seen in it.)
For example, in the user login instance above, if the method of the function module is used, the code may be like this:
The method of adopting a package package may be like this:
Perhaps you will feel that there is no difference in the code (or even the code using the function module is more concise because you don't need new objects), and the true different is in the file of include. The method of using the function module will organize the relevant function set in a file (some systems can't do this, then there will be abnormal chaos), and the method of using the package package is declared in each file and The same class is the same class (such as in Member.inc.php declares a member class, this point and Java's regulations are similar); Perhaps some people will be "simple" to compile all of the function include in each page - php is not as Java, and the light will take a period of time), but the key is to adopt a method of encapsulation. It can be clearly specified in the call location - a method (login): this is very successful from the perspective of the name conflict; for code inspection and maintenance, the convenience is more It is self-evident. Imagine that a page needs to complete several functions, thus need an incultiplex number file: The method of using the function module cannot be easily enabled from the function call (if the function name or the include file name does not have any uniform rules, then this work It is very difficult), and the way to use the package can accurately determine the location of the class method code according to the class name and class file name. (Maybe you will think that such a small benefit is not enough to do, but maybe there will be no objection after a maintenance project.) The above is the reason for the type package method, decided to adopt this method design system is just the first step. There are many experiences that can be used to complete the design of the entire system.
Some design can learn from the object-oriented ideas. Although there is no definition of interfaces and abstract classes in PHP, the inheritance mechanism is also very incomplete, but at least the basic class definition and simple inheritance relationship. Similar to "Company - Employees", "Seller - Products - Buyers" can be easily defined in the system through class and class relationships. Since PHP can do this, it will be defined according to the actual logical relationship. Another situation that often appears in the system is about the relationship between individuals and lists - so that it may be difficult to understand, imagine that there is a list of posts in a BBS system and between each post, is this relationship. According to design experience, such relationships are present in PHP or other web systems. For such relationships, I personally recommend the following Item and Item_List class package:
Item class definition: Item.inc.php code; item_list class definition: iTem_list.inc.php code. Since PHP's member variables and methods for classes do not have syntax access restrictions (all public), some confusion in object use is brought. Based on this, it is recommended to control this in the code specification of the development team. From the level of the code application: First, the property can be explained by the annotation of the member variables and methods, and other developers of this object can be used. You can understand whether your usage method has violated the specified access restrictions. (If you use PHPDOC and other automatic documents generated, developers can even use it correctly by browseing class documents without licking the source code.) Second, some main, often need for the consideration of member variable access restrictions Variables accessed or changed (in the comments) declared as disclosure. Such a method can save a lot of GET () and set () methods - although this is considered very ugly in other object-oriented languages, remember that PHP is not Java, as long as this is reasonable, it should be bold . From the sample code from above, you may have noticed the proportion of comments - although everyone understands the importance of comments, it still needs to be proposed. This example uses Javadoc style, using existing tools to generate documents (of course you and your development team can also define your own appropriate annotation style and document generation tool). For system analysts, you are probably the code part of your development partner after you have completed the design phase, which is likely to account for most of the framework code; the tools you communicate except those who have never been incomplete. It is the most familiar code and annotations of these programmers. Designed in the PHP system, although it is not like building an object-oriented system, it is necessary to intervene (there is no such "capital"), but it still needs some think. Logically rationality and operational feasibility are standards for the test.
(Saying the class design, I think of the IDE problem for PHP development. According to my knowledge, some of the majestic IDEs have Zend Ide, and there is also a PHP development tool for JBuilder's open tools; but most commonly used Or editor, or UltraEdit. If the existing editor can support PHP design and code implementation very much.)
Regarding View of View is View, although this part of the content is closely related to web designers, the system analysts of PHP projects (and other web projects) must also pay attention to this topic. It can be seen that the application of the MVC mode makes web developers and programmers's respective work results will not affect each other as before, and naturally improve their work efficiency (mutual relationship may be more harmonious than before). However, for system analysts, separate user interfaces are required to make many analytics work.
The first is the process of determining the entire system, which should be done in the early stages of the system design. For View View / Interface and Controller Control / Process, all required pages are generated around this process. However, it is usually possible to see the relevant parameters on the flowchart, but it is not possible to understand the contents of each page - this is the next step to analyze the user interface needs to work.
In the work of the user interface, the first step can determine the core of each page, and the user interface element (form and form field, link, etc.) that complete the process (form, and form fields, links, etc.); the second step is to determine the navigation content you need to appear in the page; Finally, it also needs to review the process. Or is the user login as an example. For /member/login.php This key page, the first step can be determined that a form should be displayed before the user is committed, the form contains two text boxes for the user to enter the user name and password; and after the process is based on the process on this page There is no need to have a user interface, which is replaced by redirecting using the Controller Control / Process. The second step needs to be developed (accurately said when displaying login forms) The navigation link needs to be provided, where you can add a link to the starting point of the system or other non-registered user page (convenient user temporary decision cancellation Login) and a link to log out existing users (for logged in users). After the review, this design will find that this design does not seem to take into account the better difference between the administrator is the administrator login or the ordinary user login, then add a hidden domain in the form indicates that the user who seals the login is prepared. The administrator is also logged in with the identity of ordinary users. Determining the element of the user interface does not mean that these analyzes can be delivered to the web design personnel; the most critical step is not implemented - the variable name required to formulate the template for the various pages completed. For the above user login instance, if the system has the ability to log in to the user (the relevant cookie value set on the client is based on the previous access) and the user name is displayed in the user name column of the login form, it is required. Member_login.dwt Design Description This form field will be assigned to a template variable (such as {username}). This step can be delivered after the completion of this step.
It should be pointed out that some system design needs to be partially locally in the coding phase, which may include modification of the web page template and need to be carefully processed.
There are also several files and directories for code organizations. There are not mentioned above:
Config.inc.php - If you are familiar with PHPMYADMIN or other phpwizard.net, it should be very clear that this file is very clear: Define global variables within the scope of this project (in each page). I personally think this is a very good design, so I also advocate it in the project. In addition, in order to ensure conflict with other variables in the project, it is recommended to define a multiple group in this document, and various global variables appear in a certain value of the array. This makes it easy for other developers in the team to avoid the use of a variable name, rather than avoiding variable names that appear in all config.inc.php. Another benefit using this file is due to the concentration of critical variables (such as variables related to server environments), which can be easily installed and transplanted throughout the project. Security.inc.php - As the name suggests that this file is controlled and implemented the entire system security policy. Regarding security issues, it can be thought of two control schemes: Controls this page at the top of each control process page and uses a control file throughout the control and is added to each control flow page. I personally advocate the latter way, the reason is also very simple: it is a simple definition and convenient maintenance. Although it is defined separately than each page, it may lose a little efficiency (some of the pages that do not need security control also need include this file and discriminate), but it is a convenient control of the system security and the convenience of code maintenance (loss) An IF ... ELSE ... Judgment exchange such a result is still worth it). / Temp - It is clear that it is a temporary file in this directory, and this directory does not appear in the officially released version of the project. If the use of some functions is not very clear, there is no relevant experience in the test, and the file can be established in this directory; because the directory is located in the project code, it can be very convenient to obtain the context environment of the project. It greatly reduces the cost of the test code. / admin - usually on the background management content of the system should be placed in a separate directory, I personally prefer ADMIN's simple words (of course, there are some cases of system analysts think that you should not set an easy speculation management directory name to increase one heavy Protection of system security). / CSS and / Scripts - is also with web design is also the file storage associated with the View view / interface, which is the style sheet and the client script. The benefits of doing this will be mentioned in any books that describe the website planned. Solution 2: Simple website project system performance is the primary goal of this type of project, and at the same time, the maintenance and expansion of the system can almost not use more consideration. (Perhaps this sentence is somewhat absolute, but according to customer needs and project nature judgment, the most likely to meet customer needs with the shortest time and make the system efficient operation are the best inspection standard for project success.) So, perhaps this The class project is the paradise of PHP hackers (I used to be a person who excessively pursued PHP use efficiency). Due to the particularity of this type of project, the scope of discussion here is not only limited to system design but from the process of forming a project team until the delivery project.
First, you need to pay attention to the selection of the participating items (although this is the responsibility of the project manager, the system analysts that are most familiar with PHP project should participate). In terms of PHP developers, at least developers that are more familiar with PHP (such projects are not suitable as a newcomer as a reality project, if the company is able to understand PHP in the source level More ideal (but usually impossible for general PHP development companies). In terms of web designers, it is best to choose some of the people who are slightly related to clients (such as JavaScript), and server-side (best PHP) scripts; because a major feature of such projects is that single web code is large and Mixed web code (usually html), client script (such as JavaScript), and server-side scripts (such as php), add to the purpose of finding various scripting languages, not to increase team's PHP development power, but avoid The work of the program designer is affected when modifying the web page. Secondly, the process, accurately, is a page-oriented system design. Relative to the first type of project, the customer's needs are very clear in this type of project, and companies that generally perform Web development should have certain design experiences to accumulate this type of website project. Design needs to surround the entire system, including input parameters and output contents of each page (including functional links other than the navigation links in the web page), in order to fully meet the needs of customers; another key is to determine the system Security policies, mainly in such items, mainly user-level determination and access access, and give implementation. However, it is also important to indicate that there is a lot of cases of returning design phases in such items, and changes to local design (such as page incoming parameters or output links) should be controlled.
Finally, it is optimized for code and database. The hacker attitude of the developer is required in such a project. The recommended approach is that the system analyst gives the pseudo code (frame code) of each page, and the local implementation is carried out by various program developers and web designers.
For PHP code, you can usually be considered from the following aspects:
The method of choice and functionality of the algorithm: Module level optimization can be discussed by several developers; the use of functions: the code level optimization, requires developers to have a clear understanding of various functions, at least a lot of reference The habit of the function manual; database query and change is the use of SQL statements: If the company has the management of relevant database systems, you can consult their recommendations on some optimization problems; other problems should be avoided: such as copy code, such as bad code Happening.
According to my experience, the hacker code usually written in this type of project is as follows:
The use of cyclic statements, especially when finding: At this time, pay attention to the differences of While and For (I want everyone to do this kind of program in college class), this is also a good program habit; SQL statement optimization: The first is Try to avoid excess database interaction, this is a very important point to improve efficiency; second is to use the so-called simple statement without fear of a few rows of statements; again to care about the field returned by query statements, reduce unnecessary data. Form Added value, such as check boxes, and text domains. The delicate table single field name design can reduce a certain amount of code, and the way to pay attention to the processing of the submission value.
The hacker code is worth encouraging in such projects, but it is best to comment on each code.
Due to the particularity of this type of item, the key to completing the project is not only in the system design phase, so a simple description of the project start, system design, coding, and testing, delivery of this process: selecting the appropriate personnel forming a project team, can consider selling The joining of personnel and customer representatives. System analysts can simply summarize each web page needed from the customer's needs and in the context of project experience and describe their function, while determining a preliminary security policy. This step can be added to the sales staff and customer representatives. (At this point, web designers are preparing to provide a series of website image pages to customers.) Detailed design needs to determine the location and name for each page, and more critical is to determine the input parameters and output content and the exact level of different levels of users. access permission. Database design at the same time. The flowchart of the system should be provided at least after this phase is completed, and the database design data is available. Web designers and procedures developers get their own work. For the former, design each page according to a set of visual images recognized; for the latter, "excited" (because the code is required to be high-efficient) coding work. The difficulties encountered in this phase need to feed back to the system analyst, which may return the above steps 3 or even step 2 for design modifications. After the program writing and the web design, there is a period of integration, and the program developer is self-testing the code. At the same time, at this stage can be performed is the optimization of code (including web page code and program code) and database. A complete system should be provided after this phase. The real test phase is usually more rushing. This technology and experience companies should also have a certain accumulation (if conditional wants to use some software tools to perform stability and pressure resistance test). Finally, a web access is provided for customer testing. The system that formally delivered customers can be provided after completion of this phase.
Solution 3: The comprehensive website project has some large websites using PHP as the main development language. For such items, simply worth mentioning from PHP technology, in short, it is still based on the actual application of the website (access intensity, operational behavior, etc.) to select two project design methods or integrated use. . In addition, according to my personal experience, the project team's organization and coordination work, and maintenance work after the completion of the project, etc. are more important than simple technologies.
For such projects, the recommendations that can be proposed is that appropriate adoption of some open source software is very good for fast and high-quality completion projects. Some parts of the project can be directly introduced into the design of the open source software project and even the code. However, the system designer needs to know very well on these introduced projects, while need to do these isolated open source projects and the joints between the entire project (such as Safety strategy considerations and references for global variables, etc.).
For example, according to customer requirements, a comprehensive website requires the following functions:
Complex press release; online forums that need not to manage functions; simple product display; user management is required.
(It is obvious that this is the prototype of a corporate website.)
One of the 1, 2 items can clearly borrow some mature open source software projects, and three are compared to the cost of customer demand simple independent development. It seems that 4 items are the most important part of the entire system - need to do a good job in user management integration with 1, 2 open source software items (3 due to autonomous development is very simple). (Companies with better skills have even have a simple solution to the above-mentioned integration, then the cost of such a website project is very small.)
Several special function points have some normal projects, but must be properly processed:
1. Data list paging. About this feature, there are many Chinese and English materials on the Internet. Specific technologies and implementation details don't need to be said, here only need to point out:
A. It is recommended to encapsulate a method of a tool or other reused form - such a benefit, anyone does not want the system to have almost the same code as long as there is a data list paging in the system. B. If a higher efficiency requires a higher item (such as the "Simple Website Project" type mentioned above), you should directly use the operation function of a specific database system and intercept the result set associated with the database system. Technology (SQL statement), such as the 'limit start, offset' in MySQL; other items that require system design, "design a large commercial logic project" mentioned above), if a general database is used Interface, for compatibility with multiple database systems, this interface can be used to complete the results set, with loss efficiency and scalability. That is, for the use of a specific database operation function or a third-party universal database interface to implement data list paging, you need to consider the performance of the system and the extension of the two factors.
2. Error control. This is also mentioned in the above. In addition to establishing an error class belonging to a tool class, it is best to establish a dedicated error display page. This page can be either a static HTML page (expressing some processing guidance after the user's apology and error) or a dynamic PHP page (which can contain specific error reasons and locations and other more detailed information, premise is in system security policies This information is allowed). The missing task is to accept errors thrown in the normal program, and redirect the information on the error display page after performing the necessary processing.
At the same time, it is also possible to establish a wrong page for the development phase, which can make up for the shortcomings of the existing PHP lack of violation control similar to the TRY {...} catch {...} block, and the error or output in debug is thrown and displayed.
3. Upload and download. For PHP, uploading does not require support for third-party programs like other popular web development languages, and built-in mechanisms can be handled very simple. However, it refers to some complex upload functions. Take the following to handle the process of adding additional files:
This feature allows the user to attach other files when writing new messages, and can be free to delete the attached files before the message is not submitted or continues to increase. This demand will be embodied in many office-related systems, as an experienced system analyst, should formulate implementation plans for this type of function in the system design phase. For example, in the process shown in the figure, it is actually submitted through one or more forms (specific design is no longer described, providing related PHP file reference; another intuitive example is the addition of most free mail systems) Function, if you are interested, you can find it).
As for download, put files in server web accessible directory, providing visitors real file paths are the easiest solution; but some system downloads are based on certain security policies need to be identified. This way will bring hidden dangers. The usual way may be placed in a server file system that places the file in the Web accessible directory or stores into the database system - all requires a simple program to obtain the file content and return to the requested user (this involves some The problem of HTTP output heads Please note that a PHP file is provided instead of the specific description). The corresponding approach can be adopted for different needs during system design.
4. The existing version of the customer session Session has built-in support for Session, usually in this way; some special needs projects (such as distribution systems) may adopt complex processing methods.
At the client, it is usually used to set up cookies to identify a specific customer, and the other method that can cope with the client that does not support cookie is to use the URL to rewrite the string sufficient to indicate a particular customer. From this regard, it is the most ideal for PHP built-in session support because it can automatically perform the client's Fallback: If the client supports cookie, then it will be natural; if the cookie is not supported, use the URL rewrite method - - Everything does not require developers intervention. If you use other session processing, or write the SESSION library that you adapt to you, you need to pay attention to how to deal with the client storage data - Cookie or URL rewriting or both. On the server side, simply simply requires the data that is related to each particular customer store indicated by a string - a variety of ways that can be used, and the usual way is the files and databases. In the PHP built-in session support, the default support method is to create a file in the system's temporary directory or the developed directory; of course, you can also modify the settings or other ways of setting it to support the database. If you write a Session library yourself, choose a suitable storage method according to the needs of the system. It is worth pointing out that for the distribution system, how to share the server-side session information is very concerned.
In addition, when setting the session variable, the PHP built-in session library supports the object as a variable value (actually all variables, whether the general variable is still array or object, is stored after serialization), also That is, the following code is available:
This is beneficial for some of the commercial systems mentioned above: First, you can use the user's object as a session variable value to store a set of information, not a plurality of session variables; second, if you have a shopping cart Function, the shopping cart object can be placed in the session in the session in a very compliant design of the entire system design (ie, the commercial system described above, emphasizing class package).
5. ... Other function points related to specific projects ... If it is foreseen in the system design phase and solves these functional points, even if there is a small number of unspecified function points, it is not terrible - usually Such omissions do not affect the architecture of the entire system, just need to return to the design phase to join the appropriate content and documentation. After all, for system analysts that are less abundant in related projects, it is not practical to do this type of function in the design phase.
About other controversies for PHP, but since Java's advantages in Web have become increasingly entering people's vision, this argument has a good fortune - it seems that everyone has reached a consensus - php is still a rigorous commercial system or Capable. However, based on this, it is not aware of the application of PHP in the commercial system. After all, PHP also has low cost advantages (here the cost includes development costs, cost and maintenance costs). The purpose of this article is to tell some of the PHP system design, and it is also desirable to attract some developers or enterprises to build a suitable commercial system with PHP.
In addition, this article is just some of my own experience. If you have some ideas you have in this time, I am very happy to share with you - can drive the development of open source software such as PHP, after all, is one Part of a very exciting thing. (From this point of view, I even want to write documentation and demonstration projects on PHP development, just like Sun Microsystems released by J2EE, the BluePrint and Java Pet Store, which is temporarily being temporarily subject to time, energy and personal capacity - perhaps Spring Festival holiday is a good time :)
Reference
Articles and code mentioned in this article
Code: User Login Instance (Control Page Index.php, Login.php; Web Template MEMBER_INDEX.DWT, MEMBER_LOGIN.DWT; Logical MEMBER.INC.PHP); Code: Class Package (Item Class Definition item.inc.php; Item_list.inc.php); Code: Upload Instance (Control Page Add.php, Attach.php); Code: Download Instance (Control Page Download.PHP); Code: The two global files in instance code organizations ( Config.inc.php, security.inc.php); article: About PHP's future; article: Template is used in PHP. Other References PHP official website - http: //www.php.net contains software and documentation and usage, etc. (Recent trends in this article is released in PHP 4.1.0, which has great improvements in certain aspects). Zend.com with commercial support for PHP - Http: //www.ze.com contains PHP-related tools and text data (you can find some topics related to this topic). The famous open source project website SoureForge - http://www.sourceforge.Net Open Source Project Gathering, and provides Web-based various convenience tools (which can be found for thousands of PHP writing).
About the author Wang Chen, a web developer, and is interested in writing and translating articles related to their own technology hobbies (more like others call yourself patrick when work and publishing articles). I have focused on PHP, and now there is more hobby lies in Java; it is also one of the advocators of Open Source. I often like to visit the bookstore when I am leisure; I often move around the home and near the alma mater - graduated from Southeast University. You can contact him by email patrickwang@163.com.