Reputation: 3689
I'm using the command line to execute my php scripts instead of executing them in the browser, so I can look for errors a bit quicker. For browser there are some auto-refresh applications/plugins, so you don't have to hit CMD+R all the time.
For my error log I can use the tail -f
command, but sure enough it doesn't execute/compile, so I can't use it for php files in the command-line.
Is there some equivalent or any work-around for compiled php-files ? Would be even greater to only output something in case of an error (native php-error like warnings, notices)!
Working on mac os/x if that's somehow helpful.
Upvotes: 3
Views: 3850
Reputation: 198131
You can tail -f
the error log (enable PHP to log all errors, warnings, notices into a file, tail & follow it).
Also checkout notification scripts which will create a bubble if something happens, e.g. something like How to get a pop up notification of a PHP error.
Otherwise work with a terminal/shell and just press the up arrow key and you'll have the last command you can then fire-up again. Probably ctrl+r works to search the history of commands as well under OSX.
Upvotes: 2
Reputation: 101251
The watch command does what you want.
watch - execute a program periodically, showing output fullscreen
You can do something like:
watch php myscript.php
and it would execute that command every two seconds and report it's output.
It even has flags to highlight differences from previous output.
Upvotes: 3
Reputation: 47321
Combine with OSX command :-
while [ 1 ]
do
php -r THE_FILE | grep -Ei "notice|warning|error"
sleep 5
done
Upvotes: 1