Git Product home page Git Product logo

typo3_debugbar's Introduction

TYPO3 Debug Bar

Latest Stable Version Total Downloads Latest Unstable Version License

This is a package to integrate PHP Debug Bar with TYPO3. It uses several hooks to include the assets and itself into frontend output. It bootstraps some Collectors to work with TYPO3 and implements a couple custom DataCollectors, specific for TYPO3.

Read the documentation for more configuration options.

Info: Use the DebugBar only in development. It can slow the application down (because it has to gather data). So when experiencing slowness, try disabling some of the collectors.

The extension comes with the default collectors:

  • PhpInfoCollector: Show the PHP version
  • MessagesCollector: Collects messages from within the Application and pushing them to the DebugBar
  • TimeDataCollector: Here you can start and stop a timer. Default it times the Application. More in the Usage section
  • MemoryCollector: Show the Memory usage
  • ExceptionsCollector: Collects exceptions from withing the Application and pushing them to the DebugBar

And includes some custom collectors:

  • InfoCollector: Show the same information like the Info pane of the Admin Panel
  • MySqliCollector: Show all queries, including timing and the values of prepared statements
  • Typo3Collector: Show the TYPO3 version, Locale and Environment
  • AuthCollector: Show the username of the logged-in backend user
  • SessionCollector: Show session data

Installation

Require this package with composer. It is recommended to only require the package for development.

composer require konafets/typo3_debugbar --dev

Afterwards you need to activate the extension in the Extension Manager. The DebugBar is enabled by default and will be displayed to you if you are logged into the backend as an administrator.

Usage

The extension is configurable through the Extension Manager. There you can enable/disable the DebugBar as well as the DataCollectors.

Configuration

Use it everywhere

The Typo3DebugBar implements the SingletonInterface, therefore you can get the same instance via debugbar(). This opens the possibility to interact with the DebugBar from within TYPO3.

Log Exceptions

try {
    throw new Exception('foobar');
} catch (Exception $e) {
    debugBar()->addThrowable($e);
}

These will be shown in the Exception pane.

Add messages

debugBar()->info($object);
debugBar()->error('Error!');
debugBar()->warning('Watch out…');
debugBar()->addMessage('Another message', 'mylabel');

Add timers

And start/stop timing:

debugBar()->startMeasure('render', 'Time for rendering');
debugBar()->stopMeasure('render');
debugBar()->addMeasure('now', TYPO3_START, microtime(true));
debugBar()->measure('My long operation', function() {
    // Do something…
});
debugbar_debug($value);

or even shorter:

startMeasure('render', 'Time for rendering');
stopMeasure('render');
addMeasure('now', TYPO3_START, microtime(true));
measure('My long operation', function() {
    // Do something…
});

Database

This pane shows all issued queries of the connection with the name Default. Is there is no connection with this name, the first connection of the ConnectionPool will be used.

With placeholders

Per default, the statements were shown as Prepared Statements, meaning the placeholders are inside the statement while the actual values are in a hidden table below each statement. To see them, click on the statement.

With params

To render the values directly inside the statements, activate the option with_params in the extension settings.

Info: The extension uses the connectToDB hook to inject Doctrine\DBAL\Logging\DebugStack as a logger to the connection. At the end of the rendering process it retrieves the Logger and shows the logged queries. Its important to understand, that the extension adds Doctrine\DBAL\Logging\DebugStack in any case, even if its not shown in the frontend. This is due to log all queries from the very beginning ... but at that point the BE User is not initialized yet and its unclear if the DebugBar is enabled or not. Classical Chicken-and-egg problem.

VarDump

Everybody knows the output of DebugUtility::var_dump() ... and everybody knows that it breaks the layout. Lets move the output to the TYPO3 Debugbar. Use Konafets\Typo3Debugbar\Overrides\DebuggerUtility::var_dump($variable) and get an output like this:

Lifecycle

As mentioned above the extension uses hooks. The following figure shows the usage during a request life cycle.

Credits

The extension is heavily inspired by the Laravel Debugbar. Thanks for your good work Barry vd. Heuvel. I also copied the idea of a ServiceProvider from Laravel.

typo3_debugbar's People

Contributors

konafets avatar peterkraume avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typo3_debugbar's Issues

Render the params into the SQL query

Currently the SQL statement is displayed with Prepared Statements placeholders and the actual values are rendered separately in a table. Add the possibility to display the values within the statement.

  • Add a config option to turn the substitution on/off
  • Substitute the values with the placeholders
  • Clean up the DB connection handling

Change namespace

Change the namespace from Konafets\TYPO3DebugBar\ to Konafets\Typo3Debugbar\ to make it compatible with TYPO3 extension folder name.

Writes file in typo3conf/ext folder

Extension seems to write a file in the typo3conf/ext folder, which should not be writeable by default. Why not using the typo3temp folder?

PHP Warning: file_put_contents(typo3conf/ext/typo3_debugbar/Resources/Public/Css/debugbar.css): failed to open stream: Permission denied in vendor/maximebf/debugbar/src/DebugBar/JavascriptRenderer.php line 867

Shipped jQuery 1.12.4 breaks my own jQuery

EXT:typo3_debugbar ships with Resources/Public/JavaScript/debugbar.js which includes jQuery 1.12.4. This breaks the jQuery that I've included in my theme extension.

Do you have any idea how to approach this problem. Maybe you can add a possibility to make the jQuery inclusion optional?

TYPO3 v9 support

Type of TYPO3 installation

  • Composer
  • Classic

Expected behavior

Support for T3v9LTS would be great!

Private folder is missing

Hi,
i get this error on install your Extensioion (1.3.1)

Fatal error: require(): Failed opening required '/home/www/......../typo3/typo3conf/ext/typo3_debugbar/Resources/Private/ExtensionArtifacts/autoload.php' (include_path='.:') in /html/typo3/typo3conf/ext/typo3_debugbar/ext_localconf.php on line 8

You have forgot the Private folder to upload (in release 1.3.1)

BR

PharStreamWrapper denies phar files from symlinked extension

TYPO3 8 LTS

  • Classic

Expected behavior

PharStreamWrapper includes the phar file

Actual behavior

PharStreamWrapper throws an error

Steps to reproduce

https://forge.typo3.org/issues/85658

Solution

https://forge.typo3.org/projects/typo3cms-core/repository/revisions/d4ca073bc1267474c48c740ec91b6f08454dc140/entry/typo3/sysext/core/Documentation/Changelog/8.7.x/Important-85385-IntegratePharStreamWrapper.rst

typo3_debugbar/Resources/Private/ExtensionArtifacts/autoload.php
$pharFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('typo3_debugbar') . 'Libraries/debugbar.phar';

Some var_dump text is too dark

Type of TYPO3 installation

  • [x ] Classic
  • [x ] Commposer

Expected behavior

Have the same styles like the official debugger DebuggerUtility::var_dump($GLOBALS['TYPO3_CONF_VARS'])

Actual behavior

Some texts are too dark, so you cannot read them

Steps to reproduce

Just compare both in frontend

\Konafets\Typo3Debugbar\Overrides\DebuggerUtility::var_dump($GLOBALS['TYPO3_CONF_VARS']);
DebuggerUtility::var_dump($GLOBALS['TYPO3_CONF_VARS']);

dark
light

Extension key "typo3_debugbar" not loaded

Typo3DebugBar::EXTENSION_KEY is set to "typo3_debugbar", while the actual extension key is "typo_debugbar", which causes an extension key not loaded exception.
I installed the extension with composer and the extenion directory within typo3onf/ext is "typo_debugbar", in PackageStates.php the package was also registered with "typo_debugbar".

Asset loading broken when not in domain root folder

Type of TYPO3 installation

  • Classic
  • Commposer (8.7.12)

Expected behavior

Assets of the extension are loaded by the browser.

Actual behavior

404 for loading JS and CSS files.

Steps to reproduce

If you have an installation where the website is not located directly on the domain, but in a subfolder, loading the assets will fail because of the leading "/" slash in the path.
www.domain.tld works fine whereas a baseUrl like www.domain.tld/web/ or localhost/customer/project does not.
Removing it ("/") from AssetsRenderer::renderHead fixes the issue.

TYPO3 10 compatibility

Type of TYPO3 installation

  • Classic
  • Composer

Expected behavior

This extension runs without problems under TYPO3 10

Actual behavior

It's broken

PS: I would sponsor this update

Improve README

Hi,

can you provide a better example for the following code from the README:

startMeasure('render', 'Time for rendering');
stopMeasure('render');
addMeasure('now', TYPO3_START, microtime(true));
measure('My long operation', function() {
    // Do something…
});

How to read this piece of code? Are all these lines necessary for a timer? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.