May Allah`s peace , mercy and blessing be upon you
Debugging PHP really sucks , I know that PHP fans will be furbishing their swords already and start praising their tools but additional software like Xdebug is not practical when used outside IDE. I hate to get confused by windows so I use only two : Browser/Editor or Terminal/Editor. Therefore, using other terminal(s) to debug makes me discomfortable.
- LETS DEBUG PHP IN BROWSER JS CONSOLE
- Outputting PHP To Browser Console
Inspired by these codes I tried to write my own , actually I didn't like the fact that all those function can log one variable at once and always need extra arguments to specify type , which means I would use the func_get_args to make it multi-arguments. But first console has 4 methods : log , warn , info , error . The only difference is the name so the use of method overloading __call($name, $arguments) is appropriate , the benefit is that we already got the arguments so no need to use func_get_args and no need to specify type.
What's left is conversions :
- Strings needs quotes.
- Objects and arrays are JSON encoded.
- Booleans get transformed to text.
The code :