1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-16 21:08:34 +01:00

766 Commits

Author SHA1 Message Date
Barry vd. Heuvel
b353a3197c Update composer.json 2017-07-21 13:47:39 +02:00
James Johnston
35fa8abe90 Use new HtmlVariableListWidget with collectors (#346)
Introduce a new HtmlVariableListWidget that is similar to
VariableListWidget but for variables with HTML contents.

Update the collectors that use the existing VariableListWidget to use
DebugBarVarDumper to dump the variables using the VarDumper HtmlDumper.
Because many debug bar users may not yet support inline static assets,
default to use the old VariableListWidget for now.

Updated collectors:

* ConfigCollector
* RequestDataCollector
2017-07-21 13:35:58 +02:00
James Johnston
54214dadb6 Update MessagesCollector to support HTML var dumping (#345)
Use the new DebugBarVarDumper class to support dumping variables in
interactive collapsible HTML; the new useHtmlVarDumper() function will
enable this.

Since this will require users to handle the new inline assets provided
by the JavascriptRenderer, make this dumping format optional and default
to the old behavior for now.
2017-07-21 13:35:32 +02:00
James Johnston
7102278c9e RequestIdGeneratorInterface now returns more random values (#336)
Implementers of RequestIdGeneratorInterface::generate() need to be sure
that each call to generate() will return a unique ID.

This could fail to happen in the existing implementation if microtime()
returns the same value on two successive generate() calls that come
within the same microsecond.  For example, in a tight ID-generating
loop.  It was unlikely, but now it is practically impossible.

Additionally, implementers should make sure that the return value is not
all-numeric to avoid any mixed data types when IDs are used as keys in
PHP arrays.  (For example, numeric IDs could result in bugs when
array_merge is used.)
2017-07-21 08:20:20 +02:00
James Johnston
ba8bf739c0 Show memory usage actually allocated by user PHP code (#321)
The memory_get_usage and memory_get_peak_usage functions have a
$real_usage parameter.  Update the MemoryCollector and PDOCollector
collectors to use a value of false instead of true.  For
MemoryCollector, we allow the user to choose which type of memory usage
to gather.

To recap, when $real_usage is set (and previously this was the
hard-coded default), PHP returns the amount of memory allocated from the
operating system by the PHP memory manager.  This is typically done in
large chunks of memory and is not very granular.

When $real_usage is cleared, PHP returns the amount of memory the user’s
application has actually allocated from the PHP memory manager.

Clearing $real_usage has useful application especially for the
PDOCollector.  As an example, a query that returns only a few rows will
often say that zero bytes were used when $real_usage is set.  That’s
because PHP was able to satisfy the memory requests from memory it had
already allocated from the operating system.  To contrast, the same
query will show an expected few kilobytes of memory usage when
$real_usage is set to false.
2017-07-21 08:11:10 +02:00
James Johnston
5fc3605f75 Improve efficiency of memcached find (#342)
The find function for memcached storage is not very efficient when a
large number of debug bar frames have been stored over time.  Improve
the performance by:

1.  Retrieve no more items than absolutely necessary.  (i.e. don’t
    retrieve every last possible item and then slice the result array.)

2.  Use bulk retrieval getMulti function with memcached.
2017-07-19 15:33:12 +02:00
James Johnston
13993afffe Introduce DebugBarVarDumper for HTML variable dumping (#344)
The Symfony VarDumper component includes an HtmlDumper that dumps
variables in a rich HTML format that allows for expanding and collapsing
individual tree nodes in the dumped variable.  This makes it much more
practical to navigate large/deep variables that have been dumped.

DebugBarVarDumper provides a Debug Bar-friendly wrapper around the
VarDumper component.  It’s intended as a better alternative to
DataFormatter::formatVar.  It provides for:

* Debug Bar-friendly styles for the VarDumper HTML.

* Implements AssetProvider for returning VarDumper static assets
  (requires users of JavascriptRenderer to support inline assets).

* Simplifies VarCloner and HtmlDumper function calls for cloning and
  dumping variables in a Debug Bar environment.  VarDumper was
  originally written/targeted to be a replacement for var_dump, so the
  default behavior of HtmlDumper echoing static assets and variable
  dumps directly to the page output isn’t really appropriate.
  Furthermore, we must contend with several different Symfony versions
  going back to v2.6.0.  This class provides a friendly wrapper.

I have tested this with these Symfony versions:

* v2.6.0
* v2.7.0
* v2.8.0
* v3.0.0
* v3.1.0
* v3.2.0
* v3.3.0

All seem to work fine, with graceful degradation as needed.

Furthermore, the class is ready to take advantage of new features that I
added and are upcoming in Symfony v3.4:

* setMinDepth: https://github.com/symfony/symfony/pull/23515
  This feature will be valuable for the upcoming BacktraceCollector.
2017-07-19 15:29:53 +02:00
James Johnston
22cb245c6a Allow setting Memcached item expiration (#334)
Some users may wish to prevent indefinite accumulation of logged data,
especially if the Memcached cluster is shared with other production
data.
2017-07-15 11:12:08 +02:00
James Johnston
a186961e30 Set code/pre color to black (#335)
Some existing user-provided stylesheets on the page might have a
different default color for code and pre elements; set it to black:
similar to what is already being done with the root div.phpdebugbar
style.
2017-07-15 11:11:45 +02:00
James Johnston
e7e0dba82b Add line number and line highlighting support to createCodeBlock (#337)
When showing backtraces, it’s useful to:

1.  Show line numbers for each line of contextual code.

2.  Highlight the line from the backtrace.

This commit adds the functionality to widgets.js/css for doing this.
2017-07-15 11:09:01 +02:00
James Johnston
e6f0b5a48d Enable AssetProvider to support inline assets (#338)
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.
2017-07-15 11:08:32 +02:00
James Johnston
4773b2f89b Improve formatting of the data set labels (#340)
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 '/'.
2017-07-15 11:06:34 +02:00
James Johnston
f0afbcec96 Fix misc. style sheet problems with MessagesWidget (#339)
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.)
2017-07-15 11:05:43 +02:00
James Johnston
abb2a4cfda Support debug bar collection from command-line (#322)
* 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.
2017-07-14 10:36:10 +02:00
Matt Stevens
44e9d50210 localize hljs's css to phpdebugbar (#333)
currently these styles will override anything in my application, localizing them to only the debugbar seems like a good solution.
2017-07-13 22:23:46 +02:00
James Johnston
5198c9ff70 Fix incorrect duplicate statement counter in PDO collector (#323)
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
2017-07-11 07:19:19 +02:00
zarianec
f8f52221f9 Fix line breaking for tab badges (#332) 2017-06-05 14:44:03 +02:00
Barry vd. Heuvel
b4e4b40a4b Update .travis.yml 2017-05-30 11:38:04 +02:00
Soufiane Ghzal
686b041b7c Fix twig template instance check (#331)
see #330
2017-05-30 11:33:20 +02:00
Lars Moelleken
b0dbb5808c Update TimeDataCollector.php (#329) 2017-05-04 20:31:47 +02:00
James Johnston
cbdeba00d0 Add option to not immediately show AJAX requests (#315)
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.
2017-03-05 08:17:18 +01:00
Sébastien Nikolaou
7a13e2a42e Use system fonts (#320)
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/
2017-02-18 22:41:22 +01:00
Jeremy Coates
60a7809366 Added array reverse to find results (#297)
The OpenHandler modal returns results in oldest first order by default, changed storage find method so newest entries are at the top.
2017-01-19 23:01:49 +01:00
James Johnston
afee79a236 Fix front-end crash when no twig collector exists (#312)
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.)
1.13.1
2017-01-05 09:46:19 +01:00
James Johnston
f7aa6884c2 TimeDataCollector sorts measurements by start time (#313)
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.
2016-12-29 17:08:42 +01:00
James Johnston
f243e9c104 Fix bodyMarginBottomHeight-related bugs in DebugBar (#311)
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).
2016-12-24 18:24:18 +01:00
Barry vd. Heuvel
938526c695 Check for unsafe header (#308)
Some headers are unsafe to read (in Chrome), checking all returned headers will prevent these errors. See https://github.com/barryvdh/laravel-debugbar/issues/384
2016-12-19 21:49:44 +01:00
H2lsoft
e7f2b72231 Change icon to database instead of inbox (#307) 2016-12-15 09:00:32 +01:00
Steve Pavarno
cea4d73dd3 Update docs for PDOConnector (#305)
see #299
2016-11-28 19:59:25 +01:00
Diogo Gomes
fe53541800 change count for unique and duplicated queries (#304) 2016-11-25 11:42:32 +01:00
Steve Pavarno
eb69e38f71 add pdo connection name to time collector (#301)
so that we can see that a specific measure came from a pdo connection, and which connection that was.
2016-11-21 13:47:01 +01:00
Nick Edwards
b18f24deb9 forces direction of text to be ltr (#294) 2016-10-04 11:12:45 +02:00
Barry vd. Heuvel
5f49a5ed6c Update composer.json v1.13.0 2016-09-15 16:01:59 +02:00
Andy Miller
c639a84351 Added Grav to integrations (#292)
I've added Grav to the list of integrations as we've been using DebugBar in Grav for the past couple of years.  Thanks for the great project!
2016-08-28 17:57:48 +02:00
Thomas Portelange
a57db25bb3 Integration with SilverStripe (#290) 2016-08-09 16:07:21 +02:00
Barry vd. Heuvel
7c62c30a1e Add Throwables, deprecate exceptions (#281)
* Add addThrowable
* Update composer.json
2016-06-26 14:42:26 +02:00
Graham Campbell
13fed3195b Go with the most semantically correct option (#280) 2016-06-11 14:22:24 +02:00
jamiehd
91b61a53bb Change php7 errors to exception to maintain compatability with function declaration #264 (#279) 2016-06-11 14:17:26 +02:00
kot
41d982b5cf Updated/added comments for PDO Collector (#275)
* Update TraceablePDO.php

* Update TraceablePDO.php

* Update TraceablePDOStatement.php
2016-06-02 07:33:24 +02:00
Barry vd. Heuvel
e634fbd32c Update composer.json v1.12.0 2016-05-15 15:11:34 +02:00
Barry vd. Heuvel
c3268ca122 Add initial RequireJS support
See https://github.com/barryvdh/laravel-debugbar/pull/423
2016-05-15 15:11:14 +02:00
Barry vd. Heuvel
e6109df274 Merge pull request #272 from tburry/svg-icons
Use SVG for icons instead of PNG
2016-05-08 18:34:39 +02:00
Todd Burry
c309685cf4 Use SVG for icons instead of PNG
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.
2016-05-07 15:53:54 -04:00
Barry vd. Heuvel
c2455dae32 Fix for minimized state (#252) 2016-04-29 15:30:52 +02:00
Barry vd. Heuvel
fb9e263d28 Merge pull request #246 from darwish/format-negative-bytes
Added support for negative numbers in DataFormatter::formatBytes()
2016-04-29 11:02:27 +02:00
Barry vd. Heuvel
9d2bc8da56 Merge pull request #251 from Pachonk/master
PHPDoc Fixes
2016-04-29 11:02:07 +02:00
Barry vd. Heuvel
4c0b624f0b Merge pull request #252 from codewizz/codewizz-dynamic-margin
Offset calculation change to body margin-bottom
2016-04-29 10:57:56 +02:00
Mike Darwish
b1f5e65c3b Added support for negative numbers in DataFormatter::formatBytes() 2016-03-17 11:31:17 -04:00
codewizz
88ba3c6724 Margin removal on minimized / closed state 2016-01-23 12:17:01 +02:00
codewizz
a238151cab Offset calculation change to body margin-bottom 2016-01-22 23:57:57 +02:00