How can I collect client error information in my PHP application?

I am building an enterprise application using PHP and Yii. I want a simple way for users to report a problem or error if someone encounters, however, it is difficult for me to decide which way to capture / record the state of the system to help duplicate the problem.

I was looking for an extension or library that integrates everything but may not exist. Otherwise, I need to look for a way to serialize the DOM for subsequent evaluation or another similar method.

Thus, the user can click the "Report a bug" button, which fixes the status of the site and displays a pop-up window with "what happened?". text field that the user can fill in.

What are my options for this?

+4
source share
2 answers

Take a look at Airbrake (formerly known as Hoptoad) and php notifier . By default, they do not save the full DOM code, but I think you can extend the notifier to do this.

So that users can run reports, you can use ajax plus a custom exception.

They have free plans and the setup is pretty simple.

enter image description here

+4
source

To get the HTML source code for the current page, you can use this Javascript snippet:

var htmlSource = document.getElementsByTagName('html')[0].innerHTML; 

Another piece of information that you might want to keep is, of course, the current URL. You can send all this to the server using jQuery.post , for example

 $.post("<?php echo CController::createUrl(...); ?>", { url: document.location.href, html: document.getElementsByTagName('html')[0].innerHTML, }); 

I do not think that you can do more than without any server-side helper that you can call. What function do you need specifically for this error reporting function?

+1
source

All Articles