Add new inline_css, inline_js, and inline_head keys on the
AssetProvider::getAssets() function. This allows us to support
collectors that require static assets that are not actually saved to a
file.
Then, update all the asset functions in JavascriptRenderer to support
these new keys.
An initial use case for this is supporting the HtmlDumper in Symfony’s
VarDumper. HtmlDumper only provides the styles and scripts in inline
HTML form. The static assets can be customized based on some
configuration properties available on the HtmlDumper class. One can
actually view the CSS/JS as a long PHP string/heredoc embedded in the
HtmlDumper.php source code. They are only accessible via the
getDumpHeader function, which returns the CSS/JS in a combined HTML
string.
If the URI ends with a trailing '/', then the existing code would just
show an empty string as the label, which isn't very useful if a page is
making lots of varied AJAX calls to URIs that end with trailing slashes.
Fix this by detecting if the URI ends with a trailing '/'. If it does,
then we also include the segment of the URI just prior to the
trailing '/'.
1. The list of messages was missing padding-bottom, causing the search
box to obscure the bottom message.
2. Explicitly declare styles for text input elements to avoid
interference from the containing page’s stylesheet. (On our site,
text input elements had 10px padding, causing the search box to be
much larger than the padding-bottom margin allowed for.)
* Support debug bar collection from command-line
It can be useful to use the PHP Debug Bar from the command line if a
storage layer is configured. In that scenario, a user would run a PHP
CLI application, then open a web page with the debug bar front-end and
use the open handler to locate the command-line invocation.
However, a problem is that the collect() function assumes that standard
HTTP variables are available - this assumption does not apply when
running from the CLI. Write a special branch of code for the CLI server
API so that reasonable metadata can be collected for the CLI case.
Without this patch, null method, URI, and IP are logged and it actually
becomes impossible to open the CLI invocation in the open handler - let
alone tell them apart.
* Fix gethostname call in DebugBar::collect
It might fail, and we need to be prepared for that.
The PDO collector assumes that the number of duplicate statements is
equal to the number of total statements minus the number of unique
statement query strings that had more than one query. This leads to
non-sensical statements like the following:
5 statements were executed, 4 of which were duplicated, 1 unique
when the following statements were executed. (Assume each letter
represents a particular query)
* A
* A
* B
* C
* D
Clearly there are not 4 duplicate statements under any reasonable
interpretation. After this code change, it would more correctly say for
the above example:
5 statements were executed, 2 of which were duplicates, 3 unique
By default, the debug bar will immediately show new AJAX requests. If
your page makes a lot of requests in the background (e.g. tracking),
this constant switching of the active data set can be disruptive to the
debug bar user.
This commit adds an option for disabling this behavior by calling
setAjaxHandlerAutoShow(false) on the JavascriptRenderer, like this:
$renderer = $debugbar->getJavascriptRenderer();
$renderer->setAjaxHandlerAutoShow(false);
When this behavior is disabled, AJAX requests are still available in the
drop-down list, but won’t become active until the user explicitly
selects them.
Use system fonts to match current OS UI chrome for `sans-serif` and
`monospace` fonts, giving a more consistent look with the OS and other
developer tools in the browser.
As as side note, this technique is also used by GitHub.
Read more: https://css-tricks.com/snippets/css/system-font-stack/
If the twig collector wasn’t used on a particular request, the twig
widget crashes the client. Fix the bug by assuming a default array of
zero templates.
(For example, an AJAX call that didn’t construct a TwigCollector would
trigger this crash.)
Sometimes, users of this collector may not add measurements in order of
the start time. For example, various existing measurement systems may
feed existing measurements into this class via the addMeasure function.
Sort the measurements by start time during collection. This yields a
nice, chronological view of the measurements, similar to Chrome
DevTools.
This fixes two problems:
1. In recomputeBottomOffset, if bodyMarginBottomHeight is NaN, we need
to change that to a 0 before adding so we don’t end up setting
the offset variable to NaN.
2. We now initialize bodyMarginBottomHeight in the initialize function.
This fixes a bug where bodyMarginBottomHeight gets set to NaN if the
debugbar.js is included in the page header and not the page body
(i.e. before the body element has been loaded).
As an alternative to #270 based on the suggestion in [this comment](https://github.com/maximebf/php-debugbar/pull/270#issuecomment-215638893) I’ve provided a CSS file with embedded SVGs rather than the included font awesome.
There are pros and cons to each approach, but I’d love to see vector icons in the default debug bar.