Is it possible for PHP errors to look better? Is it possible to trace on separate lines?

Right now, PHP is just unloading something like this on the page:

Fatal error: unable to update Cms \ getItemHierarchy () (previously declared in / home / cartman / Development / cmsdev / engine _1.0 / Cms / Menu.php: 62) in / home / cartman / Development / cmsdev / engine _1.0 /Cms/Menu.php on line 62 Stack call: 0.0001 634424 1. {main} () / home / cartman / Development / cmsdev / public _normal / index.php: 00 0.0037 757768 2. Bootstrap :: run () / home / cartman / Development / cmsdev / public _normal / index.php: 7 0.0037 757768 3. Cms \ Front-> dispatch () / home / cartman / Development / cmsdev / data _production / bootstrap.php: 94 0.0043 781512 4. frontendController-> contactusAction () / home / cartman / Development / cmsdev / engine _1.0 / Cms / Front.php: 367 0.0051 817152 5. plugins \ m3nu \ api-> renderMenu ($ configName = 'bottom', $ activeItem = 'contactme') / home / cartman / Development / cmsdev / data _production / controllers / frontendController.php: 43 0.0052 825392 6. Cms \ Menu-> generateMenu () / home / cartman / Development / cmsdev / public _normal / plugins / m3nu /api.php:29 0.0052 825392 7. Cms \ Menu-> preParseConfig () / home / cartman / Development / cmsdev / engine _1.0 / Cms / Menu.php: 121

Is there a way to make the output more organized, at least trace the stack trace on separate lines?

+6
source share
3 answers

This seems to be an XDebug stack trace. Try setting trace_format in php.ini :

 xdebug.trace_format = 2 # HTML formatting 
+4
source

You can also update php.ini to include HTML code for formatting.

 html_errors = On error_prepend_string = "<pre style='color: #333; font-face:monospace; font-size:8pt;'>" error_append_string = "</pre>" 

Or, if you want to install them at runtime, include the following at the beginning of script (s)

 ini_set("html_errors", 1); ini_set("error_prepend_string", "<pre style='color: #333; font-face:monospace; font-size:8pt;'>"); ini_set("error_append_string ", "</pre>"); 
+4
source

If you are viewing them from a browser, you can wrap it in

<pre></pre>

which will essentially represent your newline characters as line breaks.

Otherwise, if you are viewing outside the DOM, that is, in the console or source viewer, you will find that they are already formatted โ€œbeautifullyโ€

+3
source

Source: https://habr.com/ru/post/899252/


All Articles