PHP debugging -- there has to be a better way

I have just spent two and a half hours trying to track down the reason a page on a Joomla site suddenly started saying "You are not authorized to view this resource". In the end it turned out to be a known problem with the OpenSEF plugin, but it took me a stupidly long time to even guess that might be the problem. (Probably shoulda searched for the error message first…)

There has to be a better way to do this. The only way I could figure to trace the problem was by sprinkling lots of print "FIXME: Made it here\n"; throughout the code. I know, it's a terrible way of doing it, but running php index.php didn't seem to work — I couldn't get the code to see the arguments I was trying to pass on. What am I missing?