1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-03-16 04:09:47 +01: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
2015-12-10 10:34:48 +01:00
2014-01-16 21:41:41 +00:00
2015-12-10 10:16:07 +01:00
2017-05-30 11:38:04 +02:00
2014-10-31 20:05:09 +00:00
2014-12-17 10:51:25 +01:00
2016-09-15 16:01:59 +02:00
2014-07-26 12:00:45 +01:00
2013-06-13 18:49:55 +08:00
2014-10-27 16:08:39 +00:00
2016-08-28 17:57:48 +02:00

PHP Debug Bar

Latest Stable Version Total Downloads License Build Status

Displays a debug bar in the browser with information from php. No more var_dump() in your code!

Screenshot

Features:

  • Generic debug bar
  • Easy to integrate with any project
  • Clean, fast and easy to use interface
  • Handles AJAX request
  • Includes generic data collectors and collectors for well known libraries
  • The client side bar is 100% coded in javascript
  • Easily create your own collectors and their associated view in the bar
  • Save and re-open previous requests
  • Very well documented

Includes collectors for:

Checkout the demo for examples and phpdebugbar.com for a live example.

Integrations with other frameworks:

(drop me a message or submit a PR to add your DebugBar related project here)

Installation

The best way to install DebugBar is using Composer with the following command:

composer require maximebf/debugbar

Quick start

DebugBar is very easy to use and you can add it to any of your projects in no time. The easiest way is using the render() functions

<?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>

The DebugBar uses DataCollectors to collect data from your PHP code. Some of them are automated but others are manual. Use the DebugBar like an array where keys are the collector names. In our previous example, we add a message to the MessagesCollector:

$debugbar["messages"]->addMessage("hello world!");

StandardDebugBar activates the following collectors:

  • MemoryCollector (memory)
  • MessagesCollector (messages)
  • PhpInfoCollector (php)
  • RequestDataCollector (request)
  • TimeDataCollector (time)
  • ExceptionsCollector (exceptions)

Learn more about DebugBar in the docs.

Description
No description provided
Readme MIT 31 MiB
Languages
PHP 66.1%
JavaScript 23.9%
CSS 9.9%
HTML 0.1%