Reputation: 8791
I'm writing in symfony and I'm in one of the actions.class.php
files.
Normally I would just echo
the variable's value but because this is an actions class module, I can't do that because I can't output to the page.
I was thinking of using FirePHP but it involves installing it server-side and I'd like to be aware of an easier or built-in solution.
Upvotes: 2
Views: 99
Reputation: 12322
Emailing logs works for sure but there are some better, easier and faster ways to do that ;)
In symfony you have access to the Logger which will allow you to log anything. In prod environment by default it is disabled (of course you can switch it on) but in dev it's not only available in the log files but also prints in the Sf Web debug bar.
Inside an action use:
$this->getLogger()->debug('My $variable value is now: '.$variable);
You can also use other levels of logging (->warning('')
, ->err('')
, ->crit('')
, etc.). Of course you need to change the variable to string if it is an array or an object.
In fact you can echo
and var_dump
things while in the action. They will show in your page (though mess badly with the layout as you're displaying stuff before the actual template).
Remeber that echo
works only with strings and numbers. If you try to echo a boolean or array you will see nothing. If you try echo an object it's __toString()
method will be used or an error raised.
Upvotes: 2
Reputation: 348
Email yourself throughout the code. You could either send one at the end of the script or throughout. There are benefits to both. Emailing throughout will easily let you know where something went wrong if you don't get an email and emailing at the end save overhead(doesn't seem like it would be a problem here though).
Upvotes: 1