top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to do debugging in php?

+2 votes
382 views
How to do debugging in php?
posted Jun 6, 2014 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+2 votes

You can use eclipse, check the following link to set the eclipse environment.
http://dev.piwik.org/trac/wiki/HowToSetupDevelopmentEnvironmentWindows

Other alternative would be
http://www.xdebug.org/

answer Jun 9, 2014 by Tapesh Kulkarni
+1 vote

Programs rarely work correctly the first time. Many things can go wrong in our program that cause the PHP interpreter to generate an error message. we have a choice about where those error messages go. The messages can be sent along with other program output to the web browser. They can also be included in the web server error log.

To make error messages display in the browser, set the display_errors configuration directive to On. To send errors to the web server error log, set log_errors to On. we can set them both to On if where we want error messages in both places.

PHP defines some constants that we use to set the value of error_reporting such that only errors of certain types get reported: E_ALL (for all errors except strict notices), E_PARSE (parse errors), E_ERROR (fatal errors), E_WARNING (warnings), E_NOTICE (notices), and E_STRICT (strict notices).

answer Jun 8, 2014 by Rahul Singh
Similar Questions
+1 vote

My index.php file is compiled correctly when I use one of my PHP executables outside Apache, but fails when I ask Apache to serve it (and fails leaving a blank error log unfortunately). So I'm trying to understand how and where the two PHP compilations start behaving differently.

With my outside-Apache PHP executable, I only need to edit the php.ini file to use xdebug and get first-class debugging. I have no idea how to do the parallel analysis with Apache however. AFAIK, there is no PHP executable inside Apache, just a shared library likeat /libexec/apache2/libphp5.so, and I do not know how to debug that. Does Apache have a php.ini file also? My current system is Mac El Capitan by the way.

0 votes

We are running debian linux stable (Jessie) with apache 2.4.10 and mod_wsgi 4.3.0-1 on a x86_64 machine. Our application is written in python 2.7 and django 1.8.

The list of modules as reported by apachectl -M are:Loaded Modules: core_module (static) so_module (static) watchdog_module (static) http_module (static) log_config_module (static) logio_module (static) version_module (static) unixd_module (static) access_compat_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module (shared) authz_core_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgi_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) filter_module (shared) mime_module (shared) mpm_worker_module (shared) negotiation_module (shared) perl_module (shared) rewrite_module (shared) setenvif_module (shared) socache_shmcb_module (shared) status_module (shared) wsgi_module (shared)

We were getting segmentation faults when rest api clients were making requests. The apache error log has the following messages:

[Mon Jul 27 09:04:38.375433 2015] [core:notice] [pid 32693:tid 140315326191488] AH00052: child pid 32700 exit signal Segmentation fault (11)
[Mon Jul 27 09:04:38.375556 2015] [core:notice] [pid 32693:tid 140315326191488] AH00052: child pid 32701 exit signal Segmentation fault (11)

I have enabled core dumps by setting ulimit to unlimited and adding core dump config directive in the apache2.conf file.
but the core dumps are not happening. When I tried to debug using gdb (gdb /usr/sbin/apache2), the environment variables are not getting read. Any clues on how to go about this?

0 votes

I am using constant mainly to enable printing of debugging messages (e.g. use constant DEBUGGING_L1 => 0;)

Normally, the value is '0' and when I need to see debug messages, I make this 1 and run the script. Is there a way to allocate value to constants at run time so that I can avoid editing the script again and again?

Also, is there a better way to handle debugging?

...