📜 ⬆️ ⬇️

Debugging scripts in Zend Studio

Not so long ago, I turned to the habro-public for help in this topic . Then, not only did they not help me, but they also mined karma. Therefore, I had to understand myself ...

So today I will talk about local debugging of PHP code. There are many ways. Starting from the notorious var_dump and die () and ending with xDebug and FirePHP. I’ll tell you about, in my opinion, the most convenient debugging method - debugging in the Zend Studio environment. Version 5.5.0 for Windows will be considered. PDT users bundled with ZendStudio can use xDebug, as described in this article .

To complete the work we need 3 components:
  1. Zend Studio 5.5 itself
  2. Zend Debugger Library
  3. Zend Studio Toolbar for Firefox


After installing Zend Studio, you need to put the library to debug. Stop the web server. Select the version in the archive that corresponds to your version of php, and copy it to the directory with PHP-libraries. Next, open php.ini and add the following lines there:
')
zend_extension_ts=path/ZendDebugger.dll
In this line we specify the full path to the library.

zend_debugger.allow_hosts=127.0.0.1
zend_debugger.expose_remotely=always


Start the server and watch phpinfo. The following section should appear there:

phpinfo

From the archive with the library, throw the file dummy.php in our working draft.

Next, we need to configure the debugging environment itself. Go to Tools> Preferences> Debug and make changes, according to the screenshot:
image

Now you just have to install the zend toolbar and you can start debugging our code.

So, as it happens on the example of a handler of a certain form:

1. Open the form page in Firefox. On the ZT panel, select "All pages on this site". I do not know why, but only this option works for me.
image
2. In Zend Studio we set the necessary breakpoints (breakpoints) in the script-processor of the form.
3. Submit the form.
4. After the submission, Zend Studio becomes active with the debugging process running. Also the buttons on the debug panel become active. This is what they mean:

“Step over” - exit function or file attachment
“Step out” - go to the previous line
"Step into" - go to the next line
"Go" - run the script until the first breakpoint
"Go to cursor" - run the execution of the script to the cursor
“Run” - fully execute the script

The meaning of the remaining buttons and panels, I think, is not required in the explanation.

Source: https://habr.com/ru/post/43728/


All Articles