Any helpful advise for debugging your site...?

I wish to hear suggestions from programmers about how to go about debugging your code after the first working version of a site. I don’t know b’out you all but I call my first complete working site alpha and the testing version beta and the first live site version 1.0. Then my question is working on the beta site. All this tweaking on what’s already supposed to be working.

In the latest black hole of time dilation I had duplicated a page to work on chunking it for an include. After I striped unrelated and non-nested divs, the page elements are all positioned and styled correctly, however there’s just too much data–duplicated. There’s no logic to the result based on what I removed.

And I’ll start.
Using print_r(…) on generated code was helpful. I added a class to the output to highlight the result.

Also, turning off CSS helped me in one part of the duplicated code.

I’ve posted more than a few bone-head questions here lately (mostly in CSS pages, sorry). I’m realizing my workflow is botched for testing and tweaking. I’m new to PHP and don’t understand the debugging of dynamic server data.

Chris

Again. I’m not an “application developer”. I’m dealing with truncated and smashed up development phases that overlap. Call it rapid development or call it naive if you like.

Adam you dork. Wrong thread. ROF

I want to direct this discussion away from “applications” and back on file management, error reporting, and host transition issues of my post development phase.

Back to the reason for the post and the problem in search of a solution. When I moved my site from my localhost testing server to the remote host server, many features became inoperable. It was difficult process troubleshooting these problems.

To confuse matters, I was also still making tweaks to the site based on the results of cross browser testing. Thus the file management problems included making one tweak to the layout while troubleshooting the inoperable linked CSS styles–requiring the styles to be embedded in each page. (I still maintain the CSS error is a host problem and not related to a coding error as 1. the working site was mirrored, 2. the links were rewritten using the auto-complete function of DreamWeaver API). And in my frustration I did make mistakes in the JavaScript and PHP scripts I was using that I had to resolve in the middle of this confusion.

I would wish for a testing framework, or functionality within another framework mentioned here that allows HTML, CSS, JavaScript, and PHP code to be flagged. Then direct this output to a separate window for debugging. Its confusing to have to look through the pages I worked on for months for errors.

X

You could try to restart IIS or Go to Debugging Tab from right clicking your virtual directory and check both the Debugging Flags “Enable ASP server-side script debugging”

Or this guide could help you:

  1. In a text editor such as Notepad, open the WebApplicationName.vbproj.webinfo file.
    Note In a Visual C# .NET project, this is the WebApplicationName.csproj.webinfo file
    This file is located in the application folder for the application project.
  1. Locate the following line.

    Visual C# .NET
    <Web URLPath = “http://localhost/&lt;WebApplicationName&gt;/&lt;WebApplicationName&gt;.csproj” />

  2. Replace “localhost” with the IP Address of your computer as follows.
    Visual C# .NET

    &lt;Web URLPath = "http://10.150.144.131/&lt;WebApplicationName&gt;/&lt;WebApplicationName&gt;.csproj" /&gt;
    
  3. Start Microsoft Internet Explorer. On the Tools menu, click Internet Options.

  4. In the Internet Options dialog box, click the Security tab. Under Select a Web content zone to specify its security settings, click Local Intranet, and then click Sites.

  5. In the Local Intranet dialog box, click Advanced.

  6. In the Add this Web Site to the zone box, type the URL of your project, and then click Add.

  7. Close the application, and then open the application again.

  8. On the Debug menu, click Start.

Source: http://support.microsoft.com/kb/814717

If you are mostly concerned with testing what happens when the user inputs data, and being new to PHP and server operations, one programme that you might find very useful is called Selenium and is available as a FF extension.

It can be “programmed” to press the buttons on your page and look for an explicit result.

It might seem like a bit of a mind **** at first, but persevere and if a large part of your “black hole” is actually “F5 hell” it might be worth the effort.

hint: it has one very clever feature where you tell it to “record” and then it plays back all the clicks you just made. So instead of starting at the beginning and traversing 5 screens, you press one button and Selenium does that for you - if you “programme” it correctly

This is like testing the security of your house by continually ringing the bell, knocking the doors and trying the windows though - it wont actually help much in putting errors right, but just tell you when things have gone wrong (when they were ok 5 minutes ago).

This is not to be confused with Test Driven Development or Unit Testing tools, such as Immerse is pointing you towards.

To be honest I only used it on one project where I had a bewildering number of permutations on an interface which depended upon an external webservice (API).

Nono, this is just debugging when an error occurs.
Testing entire apps etc is a whole different ball game.
There are some interesting threads in the Application Design forum about testing.

Do these solutions include testing of the complete site – performance with web engines, optimization tools, server tools, I’m just guessing here, I’m not sure what to add other than items I personally consider when transitioning into a live site.

I always use var_dump instead of print_r because it gives more (and valuable) information.

Consider the following:


$a = "Hello ";
print_r($a);
var_dump($a);

Now, the result of print_r doesn’t show the extra space at the end of the string, while var_dump does. If the problem is that somehow the extra space causes the code not to function properly, you can print_r it for hours and hours and not become any wiser. If you use var_dump however you can see it directly :slight_smile:

Beside var_dump, the framework I use catches PHP errors and shows several lines of the file causing the error, along with a stack trace of what was called to raise the error. It takes some time to understand what the stack trace actually says, but once you can “decipher” it, it’s a very handy tool!

I like where you guys are going with this. After reading an article on a few template engines I understand how useful one of these tools could be,

[QUOTE]“By simply starting a line with a ‘?’, the class will produce HTML comments that are useful in debugging.”[QUOTE]

The IDE is a great idea, of course. I read a few describing VCS and class browsers. Where classes achieve their optimum value through parent/child relationships, tracking dependencies would be more troublesome than my few buggy include files.

These all seem to involve a great deal of investment, and I’m still a beginner at PHP. As I discover where I wish to focus my work, I’m sure I’ll better be able to judge the trade-offs implicit in each of these solutions.

I’m not familiar with “watch”; however, I should invest more time into understanding the call stack and break points.

I feel as though I’m always in the same boat. For the most part my own naming and mirroring habits have managed the extent of my work and I don’t need to learn a VCS. Though I’m sure I’d pick up some useful knowledge along the way. I wonder if its the same with testing using a template engine or IDE?

Agreed. I do this in my apps too (only with DEBUG mode ‘on’ of course) and I can’t really imagine debugging code without a stack trace anymore. Plus the code excerpt really helps to find the error. Sure, it’s not anywhere near as handy as using XDebug and watching variables and errors directly, but it’s handier than just a print_r.

Why would you recommend Smarty? Just out of curiosity. A templating engine, for a templating language seems rather inappropriate.

Moving on to the issue of debugging. I suggest you get yourself a nice IDE (Netbeans, Aptana, PHPed, Eclipse PDT) etc, most of them have plugins (or built in) php debuggers which is very handy to have.

Example, PHPed has:

  • debugging with breakpoints,
  • local and global variables (including array, object handling, etc),
  • watch,
  • call stack,
  • in-place PHP shell, which you can use to modify data as you debug along.

HAHAHA @ “In the latest black hole of time dilation”

I found that doing things in OOP make life much easier. Scattering through procedural code can be exhausting, organization plays a big part in solving your dilemma. I don’t know how much experience you have but if you did look into a MVC to separate your Display (HTML/JS/CSS) from your Code I think it’d do a lot of good.

I don’t have a good idea what you are doing, but if you don’t already use a template engine that may really help your life, using something like Smarty. It has a small learning curve at first but it’s a life saver in the end, to handle all your output with smarty is much nicer.

If you use HTML Tidy in firefox to check if your page is valid html, it is also a good help, well using a template engine its really easy. Thats my best suggestion for now :stuck_out_tongue: