Debugging PHP apps
Debugging PHP can be difficult if you can’t see what is going on inside your web service. Lately I have been using a strategy of using log messages to monitor the values of variables. The log messages will go to your Apache error_log. In your PHP code add the below statement and give $myVar some value.
error_log("***** PHP -> " . $myVar, 0);
Open a console — iterm is great if you want an excellent terminal on OSX — and issue the following command. Keep in mind if your error_log file is in a different location you will need to find where your Apache installation has placed it. The tail command is perfect for monitoring the log messages as your app dumps variables. Grep will filter out just the PHP lines in your log making it easy to follow your app messages.
tail -f /var/log/apache2/error_log | grep PHP
This entry was posted in php
and tagged php
. Bookmark the permalink
. Follow any comments here with the RSS feed for this post
Comments are closed, but you can leave a trackback: Trackback URL