Use Zend studio + phpnow + Zend debugger to build a PHP server debugging environment

Source: Internet
Author: User
Tags php server php development environment
ArticleDirectory
    • 1. Prepare the Installation File
    • Ii. configuration procedure
    • Iii. Start debugging

I am mainly engaged in ASP. NET development, but sometimes I am also exposed to PhP, And I think PHP has a lot of source code worth learning. We are not learning PHP.CodeBut to learn the implementation idea of the source code.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 perform one-step debugging.ProgramTo understand the entire running process of the program.

1. Prepare the Installation File

1, PHPnow-1.5.3."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.

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.