This is mainly to do asp.net development, but sometimes also contact with PHP, and I think that PHP has a lot of source code is worth learning, we are not learning the coding of PHP, but learning the source of ideas, or to avoid strong call for algorithm.
As an unprofessional PHP developer, want to easily read and understand a PHP function module running details, build a PHP debugging environment, and then step to debug the program, to master the process of the entire operation of the program is particularly important.
First, prepare the installation files
1, PHPnow-1.5.6. "Phpnow is Win32 under the green free Apache + PHP + MySQL Environment Suite package." Simple installation, fast-built PHP environment. ”
2, ZendDebugger-5.2.14. Zend Company's PHP debugging tool or call plugin. 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 PHP industry's most famous IDE, do not know how the PHP development environment based on the Eclipse plug-in, have time to play.
Second, configure the program
1, install Phpnow. the installation package Phpnow-1.5.3.zip decompression to a place, like I unzipped to "D:\soft\PHP", and then double-click the PHP folder in the "Setup.cmd" Start installation, the middle of the installation to MySQL will prompt you to enter the database username and password , local tests are typically set to "root". After the installation is completed, enter the following address in the browser HTTP://127.0.0.1/, if successful, you will see the following screen:
Note: If you have IIS installed before your system, and IIS is running, you should stop IIS before 80 ports will conflict, although the Apache port can be modified with the "pncp.cmd" tool, but this is not recommended.
2, install Zenddebugger. unzip the Zenddebugger-5.2.14-cygwin_nt-i386.zip to the Phpnow installation directory, which is "D:\soft\PHP", and then put Zenddebugger-5.2.14rc9-cygwin_ Nt-i386 folder name changed to Zenddebugger so short file name, into the Zenddebugger directory, we can see the following file structure:
Now you want to rename the X_x_x_comp folder in the folder to php-x.x.x, such as renaming "5_2_x_comp" to "php-5.2.x" because my test environment is php5.2, so I can just change the "5_2_x_comp" folder. The change here is to wait for a moment to configure it in php.ini.
Now go to the PHP installation directory to modify the PHP configuration file, this file is usually named "PHP.ini", so that the server can load our module correctly. But the PHP configuration file in this Phpnow environment is not called "php.ini", but "Php-apache2handler.ini", how can we know the configuration file name of PHP used in the current Web server? Here's an idea: in the "D:\soft\PHP\htdocs" directory, create a phpinfo.php file and enter the content "<?php Echo phpinfo ()?>", and then open the browser to see the following information, The reverse-white display path is the path to the current PHP configuration file:
Note: The PHP configuration file referred to here is the PHP profile that the Web site relies on, not the php.ini file under the Zend Studio directory mentioned below (Zend Studio also comes with several different versions of PHP), as shown below:
Modify the "D:\soft\PHP\php-5.2.9-2-Win32\php-apache2handler.ini" file. Open the file in Notepad, move the sidebar scroll bar to the bottom, and the following configuration nodes can be found at the end of the document:
Append at its tail:
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 end up like this:
Explain:
(1) zend_extension_ts= "D:\soft\PHP\ZendDebugger\5_2_x_comp\ZendDebugger.dll" This is my comment, because this set zend_extension_ts repeat, There is no coexistence with Zendoptimizer.
(2), zend_extension_manager.debug_server_ts= "D:\soft\PHP\ZendDebugger", here refers to the directory on the line, PHP will automatically according to their version to find the following php_x_x_ X This is the DLL file under the folder, which is why we want to rename the Zenddebugger under the face directory.
(3), zend_debugger.allow_hosts=127.0.0.1/32,192.168.0.8/24, here behind the 192.168.0.8 into your own IP on the line, you can look like the following to see their own IP address:
After the "32", "24" Do not change, they are not directory name, but subnet mask type code, "32" on behalf of "255.255.255.255", "24" for "255.255.255.0".
In the browser open: http://127.0.0.1/phpinfo.php, if you can see the following information indicates that the installation was successful, pay attention to the last line "with Zend Debugger v5.2.14, Copyright (c) 1999-2008, by Zend Technologies ". Back to HTTP://127.0.0.1/we found that the Zend Optimizer support or "yes" in the Component support box shows that we Zend Debugger and Zend Optimizer are co-located (there are many tutorials on the web that don't co-exist, That's not perfect.)
3, install Zend Studio. decompression Zendstudioenterpriseedition-v5.5.0.270.rar, the Win_setup.exe file after the decompression file, the default way next down, so that Zend Studio successfully installed in the C disk. Run it, and then close it, because the default is English, we go to change to Chinese. On the C disk (that is, the Zend Studio installation), search for the file "Desktop_options.xml", as shown below.
When found, open with Notepad and find:
<customized_property id= "Desktop.language" >
<locale language= "en" country= "variant=" "/>
</customized_property>
Change the above en to en and save it, then mark the file as read-only (Zend studio automatically restarts at a specific time to change back to the default setting, and it can be set to "Read Only"). Other coding options like the following can be modified according to the actual situation:
<customized_property id= "Editing.encoding" >
<encoding name= "Default"/>
</customized_property>
For example, can be changed to <encoding name= "UTF-8"/>, in the use of Zend Studio to open code files found in Chinese garbled time can modify this option to see.
Third, start debugging
From the Start menu, locate Zend Development environment (Zend Studio) and run it. Create a new project, and in this project to introduce a good source code package, I have the source code in the "D:\soft\PHP\htdocs\cms", this CMS is the SupeSite7.0 program, in the new project debugging options set imaging the following figure, which debug Server The URL can also be an address such as 127.0.0.1, as long as several settings are synchronized:
Additionally, the Debug tab of the Tools menu preferences is set to the following figure:
Now check:
Success will show "A successful connection has been made to the debug server." dialog box.
Open SupeSite7.0 Source project, select Zend Studio built-in browser, and enter in the Address bar: http://127.0.0.1/cms/batch.search.php, here I demonstrate SupeSite7.0 search page code debugging. Now you just press the "scale Bug" button on the far left of the browser (you can choose a different debug range from the side of the triangle), Go directly to batch.search.php page debugging (if the batch.search.php page is not in edit state, that is, not open, direct debugging will automatically open, in addition, if you use F11-per-statement execution, the current debug page contains external code files will also be opened.
Press the Debug button, go directly to the source, the cursor positioned in the first statement (here I do not set breakpoints, and the F5 way to debug the program), as follows:
Now let's test the click of a button to submit the form value and capture it. Like the following figure, click the "Search" button to see the keyword "What is CMS?" Is how it is handled. You must operate in order like this: open http://127.0.0.1/cms/batch.search.php-> input keyword "What is CMS?" -> Click the "Search" button-> click on the "Scale bug" button on the browser toolbar.
After debugging we can see "What is CMS?" What variables are stored and processed. The following figure:
At this point, the entire Zend studio+phpnow+zend Debugger server debugging environment has been built and demonstrated the use of the method.