TOC
The editor:

Debugging

TSW WebCoder debugging Debugging allows you to step through the execution of your code, monitoring what it does and how it works. It's a bit difficult to explain, unless you've tried it before, and if this is your very first time working with a programming language, you may wish to wait a bit before setting up and using debugging. On the other hand, debugging can be a huge help in finding those pesky bugs, and it will make you a much stronger coder. It's really up to you whether or not you wish to setup debugging now or wait until later on.

In previous chapters, we installed both Apache and PHP on your machine. Thankfully, that's almost everything you need, to make debugging possible for you. In TSW WebCoder, go to the Debug menu and select Setup debugging. You will be presented with a wizard, which will walk you though the entire process of setting up debugging on your machine. It's pretty straight forward, but just in case, I will walk you through the wizard to make sure that everything goes as planned.

  1. On the first page, you don't have to do anything. It's simply a welcome screen.
  2. On the second page, you should keep the default selection of setting up full debugging.
  3. On the third screen, there's a bit of information of Apache and PHP, but since we already installed that, we can just move on.
  4. On the fourth screen, you should tell WebCoder where to find your php.ini file. If you followed the directions in this tutorial while installing PHP, and didn't change the path, it should look something like C:\Program Files\PHP\php.ini. Click the browse button to locate it.
  5. Now, on the fifth screen, we need a DLL file which will allow PHP and Apache to communicate with the debug client inside of WebCoder. You can get it from http://www.xdebug.org/, by selecting the DLL that fits the version of PHP you installed to the right of the website, under Windows binaries. Download it to the ext directory of your PHP installation, usually C:\Program Files\PHP\ext\. Once it's downloaded, find the path in WebCoder by clicking the browse button to locate it.
  6. On the next screen, you should leave the settings as they are, unless you have a specific reason for changing them. The default values should work just fine.
  7. Now it's time to modify the php.ini file, to enable the Xdebug module we downloaded. WebCoder will do this for you, if you simply click the Modify button. After the modification, Apache will require a restart to pick up the changes, in case it's already running - this step is rather important, so if it is running, restart it. Otherwise, now would be a fine time to start Apache up.
  8. On the next screen, you should locate your document root for Apache in the first textbox, and the localhost path in the second. If you followed this tutorial and didn't change anything, the values entered should look something like this:

    Document root: C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\
    URL: http://localhost:8080/
  9. On the next screen, we can test if everything worked the way it should. Make sure that Apache is started (and restarted, as described after the modification of the php.ini file) and then click the Test button. If everything goes well, you are now ready to debug!