Jun 27 2012
Finding Out Where a Method is Being Called From in PHP
If you don’t have a debugger setup or would rather just see this sort of information in a log format use this snippet to find where a method is being called from. Note, if you have NetBeans configured with XDebug you can add a break point and watch the callstack for this sort of information.
$trace = debug_backtrace(); //$cache = "$key ".json_encode($value)." $duration"; $cache = ''; $caller = $trace[1]['file'].':'.$trace[1]['line'].' '.$cache; error_log(__METHOD__.': '.$caller); |
The output will go to where you apache error log is, typically /var/log/apache2/error.log:
[Tue Jun 26 17:29:22 2012] [error] [client 127.0.0.1] ApcEngine::write: /var/www/project/admin/config/bootstrap.php:173 , referer: http://localhost/page |
Enhanced PHP performance profiling with Xhprof Scrape Faster with PHP DomDocument and Safely with Tor

