DebugBar is a free and open source application that can be integrated into any PHP project and collect and display analysis data.
Does it have any dependencies? It supports Ajax requests, including general data collectors and collectors of commonly used development libraries.
I believe that students who have used Laravel's debugging tool feel that this tool is very powerful and easy to use, which greatly improves the productivity of programmers. In fact, Laravel is the tool It is upgraded from the open source php-debugbar
.
How can we use this native php-debugbar debugging tool in other platforms frameworks
?
This debugging is managed using the composer
package. Let’s go to Github
first. See how to use:
maximebf/php-debugbar
composer require maximebf/debugbar
<?php // Require the Composer autoloader, if not already loaded require 'vendor/autoload.php'; use DebugBar\StandardDebugBar; $debugbar = new StandardDebugBar(); $debugbarRenderer = $debugbar->getJavascriptRenderer(); $debugbar["messages"]->addMessage("hello world!"); ?> <html> <head> <?php echo $debugbarRenderer->renderHead() ?> </head> <body> ... <?php echo $debugbarRenderer->render() ?> </body> </html>
When using, if the static resource of the package is not loaded, the source code needs to be modified, because the source code is static The resource path cannot be found in the local server. The root URL of the source code uses a relative path under the server, such as: http://localhost/vendor/maximebf/debugbar/src/DebugBar/Resourc
This path , and our package is placed in a directory like http://localhost/web/php-debugbar/vendor/maximebf/debugbar/src/DebugBar/Resourc
under the server, so we need to JavascriptRenderer.php
The $baseUrl
of the file variable is modified:
The location of the file:
vendor/maximebf/debugbar/src/DebugBar/JavascriptRenderer.php
// 原来的 $baseUrl = '/vendor/maximebf/debugbar/src/DebugBar/Resources'; // 修改后的,只加了一个表示当前路径的点 "." $baseUrl = './vendor/maximebf/debugbar/src/DebugBar/Resources';
The above is the detailed content of Detailed introduction to using the open source DebugBar tool to debug PHP code (pictures and texts). For more information, please follow other related articles on the PHP Chinese website!