I am mainly engaged in ASP. NET development, but sometimes it will also come into contact with PHP, And I think PHP has a lot of source code worth learning, we are not learning the PHP code writing, but learning the source code implementation ideas, or do not call it an algorithm.
As a non-professional PHP developer, he wants to easily understand and understand the running details of a PHP function module, build a PHP debugging environment, and then debug the program in one step, it is particularly important to know the entire running process of the program.
1. Prepare the Installation File
1, PHPnow-1.5.6."PHPnow is a free green Apache + PHP + MySQL environment package under Win32. Simple installation and quick setup of the PHP environment ."
2, ZendDebugger-5.2.14.Zend's PHP debugging tool or plug-in. Http://downloads.zend.com/pdt/server-debugger/ZendDebugger-5.2.14-cygwin_nt-i386.zip
3, ZendStudioEnterpriseEdition-v5.5.0.It is said that the most famous IDE in the PHP industry does not know how to develop the PHP development environment based on the Eclipse plug-in. I have time to talk about it.
Ii. configuration procedure
1. Install PHPnow.Decompress the phpnow-1.5.3.zip installation package to a place, as shown in "D: \ soft \ PHP", and double-click "Setup. cmd "to start installation. When you install MySql in the middle, you will be prompted to enter the database username and password. Generally, the local test is set to" root ". After the installation is complete, enter the following address in the browser: http: // 127.0.0.1/. If the installation is successful, you will see the following screen:
Note:If your system has already installed IIS and IIS is running, stop IIS first. Otherwise, port 80 may conflict, even though "PnCp. cmd "tool can modify the Apache port, but it is not recommended to change it like this.
2. Install ZendDebugger.Decompress zenddebugger-5.2.14-cygwin_nt-i386.zip to the PHPnow installation directory, that is, "D: \ soft \ PHP", and then change the name of the ZendDebugger-5.2.14RC9-cygwin_nt-i386 folder to a short file name such as ZendDebugger to the ZendDebugger directory, we can see the following file structure:
Now I want to rename the X_X_x_comp folder in the folder to the php-X.X.x, for example, rename "5_2_x_comp" to "php-5.2.x", because my test environment is php5.2, so I can only change the "5_2_x_comp" folder. The change here is to wait for php. ini to configure it.
Now, go to the PHP installation directory and modify the PHP configuration file. This file is usually named "php. ini" so that the server can load our module correctly. But this PHPnow environment PHP configuration file is not called "php. ini", but "php-apache2handler.ini", how can we know the current WEB server using PHP configuration file name. The following is a method: In the "D: \ soft \ PHP \ htdocs" directory, create a phpinfo. PHP file and enter the content "<? Php echo phpinfo () ;?> ", Open the browser and you will see the following information. The reverse white display path is the path of the current PHP configuration file:
Note:Here, the PHP configuration file is the PHP configuration file on which the website depends, not the php under the Zend Studio directory mentioned below. INI file (Zend Studio also comes with several different versions of PHP), such:
Modify the D: \ soft \ PHP \ php-5.2.9-2-Win32 \ php-apache2handler.ini file. Open the file in notepad and move the scroll bar to the bottom. The following configuration nodes can be found at the end of the document:
Append at its end:
Zend_extension_manager.debug_server_ts = "D: \ soft \ PHP \ ZendDebugger"
Zend_debugger.allow_hosts = 127.0.0.1/32,192.168 .0.8/24
Zend_debugger.expose_remotely = always
It should eventually be like this:
Explanations:
(1); zend_extension_ts = "D: \ soft \ PHP \ ZendDebugger \ 5_2_x_comp \ ZendDebugger. dll" I noted this because the zend_extension_ts setting is repeated and cannot coexist with ZendOptimizer.
(2) zend_extension_manager.debug_server_ts = "D: \ soft \ PHP \ ZendDebugger". This indicates the directory, PHP will automatically find the dll file under the folder php_X_X_X according to its own version. This is why we renamed the subdirectory under ZendDebugger.
(3) zend_debugger.allow_hosts = 127.0.0.1/32,192.168 .0.8/24. Change 192.168.0.8 to your own IP address. You can view your IP address as follows:
The following "32" and "24" do not need to be changed. They are not directory names, but subnet mask type codes. "32" indicates "255.255.255.255", and "24" indicates "255.255.255.0 ".
Open http: // 127.0.0.1/phpinfo in the browser. php. If the following information is displayed, the installation is successful. Check the last line "with Zend Debugger v5.2.14, Copyright (c) 1999-2008, by Zend Technologies ". Return to http: // 127.0.0.1/. We found that the Zend Optimizer support is "Yes" in the component support box, it indicates that Zend Debugger and Zend Optimizer run together (some tutorials provided on the Internet do not run together, which is not perfect ).
3. Install Zend Studio.Decompress zendstudiopoliciseedition-v5.5.0.270.rar, and run the win_setup.exe file behind the decompressed file. The Next step is performed by default, so that Zend Studio is successfully installed on drive C. Run it and disable it. Because the default English version is used, we can change it to Chinese. On the drive C (that is, the disk where Zend Studio is installed), search for the file "shorttop_options.xml", as shown in.
Open it in notepad and find:
<Customized_property ID = "desktop. language">
<Locale language = "en" country = "" variant = ""/>
</Customized_property>
Change the above en to zh and save the file, and mark the file as "read-only" (Zend Studio automatically restarts at a specific time will change back to the default settings, if it is set to "read-only", it will be powerless ). You can also modify the encoding options as follows:
<Customized_property ID = "editing. encoding">
<Encoding name = "Default"/>
</Customized_property>
For example, you can change to <encoding name = "UTF-8"/>, in the use of Zend Studio to open the code file to find Chinese garbled when you can modify this option to look.
Iii. Start debugging
From the "Start Menu", find "Zend Development Environment (Zend Studio)" and run it. Create a new project and introduce a developed source code package. The source code package here is "D: \ soft \ PHP \ htdocs \ cms ", this cms is the SupeSite7.0 program. You can set imaging in the debugging options of the new project. The Debug Server URL can also be an address like 127.0.0.1. Just set synchronization in a few places:
In addition, the "debug" tab of the "tool" menu "Preferences" is also set as follows:
Check now:
"Successfully connected to the Debug Server" is displayed ." Dialog box.
Open the SupeSite7.0 source code project, select the Zend Studio built-in browser, and enter: http: // 127.0.0.1/cms/batch in the address bar. search. php. Here I will demonstrate how to debug the search page code of SupeSite7.0. Now you can directly press the "shell worm" button on the far left of the browser (you can select a different debugging range from the inverted triangle) to enter the batch. search. php page debugging (if batch. search. php pages are not in the editing status before, that is, they have not been opened. Direct debugging will automatically open them. In addition, if you use F11 for statement-by-statement execution, the external code file contained in the current debugging page will also be opened.
After pressing the debug button, go directly to the source code, and position the cursor in the first statement (here I didn't set the breakpoint and debug the program in F5 mode), as shown below:
Now let's test and click a button to submit the form value and capture it. In that way, click "Search" and check the keyword "What is CMS ?" How is it handled. The operation sequence must be as follows: Open http: // 127.0.0.1/cms/batch. search. php-> enter the keyword "What is CMS ?" -> Click the "Search" button and click the "shell worm" button on the toolbar of the browser.
After debugging, we can see "What is CMS ?" Which variables are stored and processed. For example:
So far, the entire Zend Studio + PHPnow + Zend Debugger server debugging environment has been set up, and the usage is demonstrated.