This is a super simple command but there is something about the following sequence of characters that I simply cannot retain in my brain.
tail -f /tmp/php-errors
This is a handy command to debug your PHP on your server where you may have errors hidden.
- The tail command shows the end of a file.
- The -f flag tells it to keep the file open, while you debug your code
- The /tmp/php-error is ( I assume! ) a temporary error log file that stores PHP errors on the server.
.
Update:
If you use error_log(print_r(debug_backtrace(), true ))
with this command, you can monitor the call stack in real time. Super useful when debugging!
In PHP you can configure errors to be logged to pretty much any file the web server can write to – http://us3.php.net/manual/en/errorfunc.configuration.php#ini.error-log
Thanks Joseph, that is useful to know.
This doesn’t even work… why would you post it? php doesn’t keep a file at tmp/php-errors. it would be useful to post where the actual php error log file lives.
@eric, does it matter where the log file resides? The content of the log file is echo’d to your terminal in realtime, that is why the command is useful for debugging.
You can use the Dephpugger project too.
https://github.com/tacnoman/dephpugger