Solved

How can I debug a php script?

Posted on 2010-09-10
6
411 Views
Last Modified: 2012-05-10
Hi,

I have a problem with a php script, I bought. Sometimes it just hangs on some operation. The script has about 3k lines, so I can't analyse the script and add debug output messages to it. Is it somehow possible to debug it? I just want to know, what (on what line[s]) the server is currently working on.
0
Comment
Question by:LL0rd
6 Comments
 

Expert Comment

by:ilevex
ID: 33648313
Try to add some debug lines only to some more important lines, then try to add to less important ones. Also look at the script's output, and try to figure out where it hangs. Give it easy vars, like 1, and calculate it in your brain. Hope I helped. ;)
0
 
LVL 3

Expert Comment

by:kf4zmt
ID: 33648489
Check the apache error.log file.  It usually has some very helpful error or warning entries regarding a misbehaving php script.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 33652880
Make sure you have error reporting turned on.  Set error_reporting(E_ALL).  But the larger question is, if you "bought" the script the seller has some obligation related to merchantability.  I would go back to the source and ask for help.  I think they would be VERY GLAD to offer assistance and would be grateful for the opportunity to remove a bug from future versions.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 1

Author Comment

by:LL0rd
ID: 33654853
First of all an external application is accessing  the script twice a day and makes the script on my server hangs. I can't Access and error logfiles does not have any information about the error, even with E_ALL. Yesterday I installed mod_dumpio on the server to get the input data, that causes problem. To my surprise I couldn't cause the hang with exact the same data, that coused it the last time. Now I also tried to add some code lines with debug output, but it didn't helped me. The problem appeared twice since than, but I got the last output from different lines. That's why I think, the problem is caused by a method or function. But I don't want to add debug output lines to every function - it's quite a lot of work.

@Ray Paseur
I have allready talked to the seller. Without any results. I'm from Germany, here people try to defend their work. So the seller said to me: "Hey, I sold this script a lot of times and you are the only customer with that problem. It must be the fault of your server. And you are the only person, who have root rights on the machine, so you can see, what is going on. And maybe the Server is not powerfull enough". But well - I also can't see, what is going on. And the machine is a Sun X4150 server with 16GB RAM and 8x 3GHz Xeon with 5 SAS HDs on a HW Raid controller with 256MB Cache @Raid5. It's a high end machine.

Well for me, it's not important that the seller fixes the bug, I just want to use the script (now and not in a few days/weeks/month, on the next release).
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 33656543
When you say it "hangs" does that mean an endless loop or an endless wait?  If it is a loop, you might be able to set a very short time limit and catch an instruction line number when the server terminates the script.

Is the script OOP code?  If so, how many methods are present?  Even with 3,000 lines of code it would not seem that hard to a few error-logging statements, perhaps one per method.  Something like that may help you if the error is data-dependent.
0
 
LVL 25

Expert Comment

by:madunix
ID: 33658057
I do php programming/debugging  with help of eclipse..
The free and popular Eclipse development environment gives programmers a feature-rich editor, version control manager, and debugger on a shared GUI. Eclipse was designed as a universal IDE that is easily extensible to accommodate a variety of programming languages. The PHPEclipse plugin converts Eclipse into a full-fledged IDE for PHP-based dynamic websites. Another plugin called Subclipse integrates version control with the Subversion version management system. In this article, we describe how to set up a PHP development environment with Subversion and Eclipse.

http://www.linux-magazine.com/w3/issue/87/PHP_Programming_With_Eclipse_IDE.pdf
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question