基于NuSphere环境调试wordpress系统

  categories:资料  author:

原创文章,转载请指明出处并保留原文url地址

前面我们介绍了基于NuSphere的wordpress系统,今天我们在相对详细介绍一下, 如何从浏览器中调用wordpress页面, 然后可以在NuSphere环境中调试页面代码。

1. 配置NuSphere环境

1)启动NuSphere,设置调试选项

wps_clip_image-25203[3][1]

从工具菜单=》settings选项,显示下面配置对话框

wps_clip_image-23616[4][1]

Default run mode options allow you to choose between local and remote servers to run your code on. For more details on run mode, see Setting the Run Mode. Chck

这个设置可以让你设置你的代码是运行在本地服务器或者远程服务器上。,更多信息请点。。。。

HTTP mode, Default browser options allow you to setup the default browser for running the scripts. You can select between embedded Internet Explorer, Mozilla or any external browser available on your system.

这个设置允许你设置运行脚本的默认浏览器。你能选择嵌入浏览器(在PhpED 环境内部运行的), Mozila浏览器, 或者在你pc上的外部浏览器(相对PhpED 而言)

CLI mode, output target options allow you to specify where PhpED should send the output of PHP script executed with Command Line Interface.

选项允许你制定PhpED环境把具有命令行接口的Php脚本输出到哪里。

PHP Version (SRV and CLI modes) options allow you to specify which version of PHP interpreter to use for running PHP scripts when the Project is set to use SRV (PhpEDbuilt-in web server) or CLI. You can choose any of PHP versions distributed with PhpED from 4.x to 5.3

这种php的版本

Default debugger settings allow you to setup your PHP debugger:

1. Use SSH tunnel  – check it if you want to use SSH tunnel to communicate with the debugger. Use SSH Tunnel options include SSH Tunnel used to specify existing tunnel name and Tunnel listening address used to identify the server on the other end of the tunnel

设置是否使用ssh通道同debugger进行通信。

2. Use custom port and host (ssh tunneling) options include Debugger port* and Debugger host* fields to identify the client machine. In Debugger port and Debugger host fields you can change the port and host choose to have them automatically selected. These settings are useful when you run a debug session through an SSH tunnel. In this case specify localhost in the Debugger host field. Debugger port should be assigned individually for each developer.

3. Error level specifies what type of errors should be shown as popup warnings. All the errors are shown in the Error tab anyway.

4. Session Wait Timeout field allows you to change the period PhpED waits for debug session to start after you press RUN IN DEBUGGER button.

5. Debugger code page allows you to set the encoding used for debugging

6. Check the box Break on Start if you want your script to be stopped on the first line after you press RUN button in debugger.

如果你想你的代码在进入的第一行处自动暂停运行(相当于设置了断点),设置这个选项

7. Check Break on Errors if you want your script to be stopped on occurence of PHP Error listed in Errors field below this check box

如果想当发生错误时, 脚本停止运行,选择这个选项

8. Check Break on Exceptions if you want your script to be stopped on occurence of Exception. Exceptions triggering this break can be listed below as well as the exceptions that should be ignored by debugger

如果想当发生异常时, 脚本停止运行,选择这个选项

9. Check Debug sessions to enable session-wide debugging. When enabled, PhpED debugs all links you click on your project site while running in debugger. When disabled, only the original php file is being debugged.

但设置了这个选项, 调试器调试在全部在项目中的链接, 若是没有设置这个选项,仅仅调试原始的php文件(在调试器开始的)

10. Check Show mapping errors if you want to see notifications about mapping errors. It works if HTTP run mode (3rd party WEB server) is selected.

11. Make editor read-only while debugging. Enable this option to prevent occasional changes in your code while you are debugging it.

12. Run profiler with debugger*. Check off this box if you want to run profiler simultaneously with debugger. Otherwise, profiler is run only when you press Profile button.

13. Save profiler history*. Mark this checkbox to save profiling results in .ppd file in the directory where you workspace files (.ppw) are located.

14. Keep profiler sessions*. Use to set the number of sessions to be kept in the profiler history. You can navigate among the profiler results by pressing BACK and FORWARD buttons. Default setting is 15 sessions.

* This feature is not available in Standard and Educational versions of PhpED.

2)配置srv web server

如下图,配置web server相关选项

wps_clip_image-12333[4][1]

On this local server you can run and debug your scripts locally.

As with any web server, the PhpED WEB server can be configured to listen to a given TCP port (set to 8080 by default). Any request from a Web browser to the specified port or proxy is sent directly to the PhpED server. Server handles the request, runs php and returns the results.

像任何web服务器, 这个PhpED web 服务器能被配置成监听在任何tcp端口(默认8080)。任何从web 浏览器发出到配置的端口或者代理的请求,被直接地发送给PhpED 服务器。服务器处理请求, 运行php然后返回处理结果。

To configure PhpED WEB server settings:

Choose Tools > Settings from the PhpED main menu, and then click the SRV web server tab.

Specify the server port (the default is 8080).

Specify PHP executables to be used for PHP 4.x, PHP 5.x and PHP 5.3 CGI Handlers. The version of PHP executed is determined by PHP version selected in Run & Debug settings. These PHP executables will be used by the Srv web server to execute files with PHP extensions. You can edit the associations in the list using ADD, EDIT and DELETE to the right. These settings are used for Local CGI and SRV local WEB server run modes. Use IDE tab to set up the run mode.

3)关于 DBGSESSID

Running the PhpED Debugger

Debugging is the process of detecting, locating, and correcting a problem in the script. Running a script in the debugger causes PhpED to step through the current file, and any included files. As the file runs, debugger output from all scripts is displayed in the Debugger window at the bottom of the PhpED main window. The debugger highlights any line of code that has an error and displays the error in the Error window. In Debug tabs you can view the value of different variables in Watch tab, Local tab, and Global tab.

Running a script in the debugger causes PhpED to step through the current file, and any included files. As the file runs, debugger output from all scripts is displayed in the Debugger window at the bottom of the PhpED main window. The debugger highlights any line of code that has an error and displays the error in the Error window. In Debug tabs you can view the value of different variables in Watch tab, Local tab, and Global tab.

There are two ways to run a PHP script in debugger mode: from within the PhpED interface, or by opening the script in a Web browser when the Debugger Listener is running and debug session is requested by supplying DBGSESSID variable.

To run a script in debugger mode from the PhpED window

为了在PhpED的窗口中以debugger模式运行一个脚本,有如下相关事项。

Set the run mode to HTTP mode (SRV local WEB server) or Local CGI (php.exe). In the PhpED window, open the script you want to debug. Press F9, or choose Run > Run in Debugger from the menu bar, or click the Run in debugger button on the PhpED toolbar.

The Debugger Listener starts, the script is run, and debugger output is displayed in the Debugger window.

设置运行模式到 HTTP mode (SRV local WEB server) 或者Local CGI (php.exe).模式。

在PhpED窗口中, 打开要调试的脚本, 按下键盘的F9按键, 或者选择run菜单中, run in debugger子菜单。

然后这个debugger监听器开始工作, 脚本运行, dibugger输出显示在debugger窗口中。

To edit code after you have detected an error, stop the debugger and edit the code. After you finish your changes, you can run the debugger again to test the result.

On Windows, the Debugger Listener starts up with PhpED. Do not shut down the Debugger Listener, or you will not be able to perform debugging until you re-run IDE. If you exit the Debugger Listener by right-mouse clicking on the Listener (satellite icon) on your system try and selecting Exit, you will only be able to restart the Listener again by restarting PhpED.

To run a script in debugger mode from a browser

In most cases you will be using the conventional method of debugging scripts by running from IDE. However occasionally you may need to debug applications using browser-based activation.

To run debugging from Internet Explorer using NuSphere Debugger Toolbar for Internet Explorer.

为了让从ie(开发环境内置的浏览器,嵌入的浏览器)浏览器发起的请求,能够被调试,使用NuSphere for ie的工具条

1. Make sure the Debugger Listener is running, and start your Internet Explorer Web browser.

确保debugger 监听器运行, 然后开始你的ie浏览器

2. Open the URL of the page you want to debug and select one of the following items from NuSphere Debugger Toolbar for Internet Explorer:

a. Debug this page – to start debugging on the open page

b. Debug next page – to start debugging after navigate to the next page

c. Debug next POST – to start debugging after the next POST action

*This feature is not available in Standard and Educational versions of PhpED.

To run debugging from an external web browser:

为了对外部浏览器发起的请求进行调试,需要如下设置。

1. Make sure the Debugger Listener is running, and start your Web browser.

首先确保debugger监听器运行, 然后启动你的浏览器

2. From a browser window, open a PHP script page by typing the URL for the script you want to debug with the additional argument of:

从一个浏览器窗口(外部浏览器),打开一个php脚本文件,通过键入你需要调试的脚本文件的url, 同时附件一个参数如下:

?DBGSESSID=0@clienthost:7869

For example, if you want to debug a script that is normally accessed using the URL:

例如,如果你要调试如下的一个url的脚本,url如下:

http://smaug:9000/shopcart/index.php3

you enter:

然后你需要输入如下代码进行调试

http://smaug:9000/shopcart/index.php3?DBGSESSID=0@clienthost:7869

3. PhpED automatically starts, the PHP script is loaded into the PhpED editing window, and any debugging information is displayed in the PhpED Debug window. PhpED will enter Debugger mode with execution paused at the first executable line. You are ready to perform normal debugging activities.

PhpED将自动启动, 这个php脚本被加载到PhpED编辑窗口中。然后调试信息被现在PhpED调试窗口中。Phped将进入调试模式中执行,同时暂停在第一条可执行语句行上。然后你可以正常的进行调试工作。

DBGSESSID is a special variable recognized by the debugger. It has the following syntax:

DBGSESSID 是调试器认识的一个制定的参数值, 他有如下语法。

DBGSESSID=id[@debuggerhost][:debuggerport][;flags], where:

· id – is a session number (ID), should be a positive number. Negative numbers prohibit debugging or profiling;

Id 是一个session号码, 必须是一个正数,负数比调试器何性能探测器禁止。

· debugger host is an address of the machine where you run IDE. Keyword clienthost can be used to get the address automatically detected.

debugger host是ide环境的机器地址。关键字clienthost 能够自动探测ide机器的地址。

· debugger port is a port assigned for debugger listener (See this topic to assign a port)

debugger port 是debugger的监听端口

· flags is a list of comma-delimited flags to start either debugger session or profiler session or both. Should be in form d={0|1},p={0|1}

Flags是一些列用逗号分隔的debugger参数,应该的形式是:d={0|1},p={0|1}

Examples:

?span style=”font-size:8pt; font-family=’Times New Roman';”>   http://localhost/shopcart/index.php3?DBGSESSID=1;p=1

?span style=”font-size:8pt; font-family=’Times New Roman';”>   http://localhost/shopcart/index.php3?DBGSESSID=1@clienthost:7869;d=1,p=0

To run a script in debugger using a URL

If you want to view or debug a file that you can access over an intranet or Internet connection, PhpED lets you open the file in embedded browser and run the Debugger on it. To open a URL:

1. Select Tools > Open URL from the PhpED main menu.

wps_clip_image-22492[4][1]

2. Type the URL address.

3. Check Run debug session if you want to run the debugger and stop at the first line of code.

4. Check Run profiler session* if you want to start the profiling session.

5. Skip sessions. Use this option to delay the actual debugging session. You might want to use this option to debug a script that runs after submitting several consecutive forms. These forms should be left before starting the debugging session. Specify here the number (from 0 to 100) of such submits.

*This feature is not available in Standard and Educational versions of PhpED

2. 浏览器测试

1) 不添加调试参数情况

打开一个浏览器, 输入如下地址(如下图)

(需要配置 windows本机的hosts文件, 配置为 127.0.0.1 www.iigrowing.cn)

wps_clip_image-27[4][1]

显示结果如下:

wps_clip_image-19562[4][1]

PhpED环境如下:

wps_clip_image-28552[4][1]

从PhpED中我们知道, php并没后进行调试工作,我们需要进一步处理

2) 添加调试参数情况

如下图,在地址栏中, 添加如下图画中 紫色区域的参数,然后获取页面

wps_clip_image-10364[4][1]

PhpED环境中设置一个断点,如下:

wps_clip_image-10090[4][1]

当在浏览器中调用了带有调试参数的页面请求时,PhpED显示如下:

wps_clip_image-15151[4][1]

从上图中我们可以看到php已经进入调试模式

3) 再次进行无调试调试参数的测试

如下图,继续在php中设置断点

wps_clip_image-25698[4][1]

启动浏览器, 然后如下图绿色区域, 去除调试参数

wps_clip_image-14519[3][1]

调用后,PhpED进入了调试模式

wps_clip_image-5020[4][1]

为什么,两次没有带调试参数的结果不同?

经过分析,在第二步带有调试参数的调用中,系统写入了一个特定的专用cookie,这样最后一次没有调试参数调用可以进入调试模式。

我了验证上述过程,我们可以清除浏览器中缓存及cookie,然后再次测试无参数的php发现没有中断进入调试模式。



快乐成长 每天进步一点点