{"id":20103165,"url":"https://github.com/dotkernel/dot-debugbar","last_synced_at":"2025-05-06T08:31:10.889Z","repository":{"id":56971390,"uuid":"440819177","full_name":"dotkernel/dot-debugbar","owner":"dotkernel","description":"Middleware on top of maximebf/php-debugbar","archived":false,"fork":false,"pushed_at":"2025-03-14T15:27:24.000Z","size":890,"stargazers_count":4,"open_issues_count":5,"forks_count":1,"subscribers_count":3,"default_branch":"1.0","last_synced_at":"2025-05-02T07:53:16.931Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.dotkernel.org/dot-debugbar/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotkernel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-22T10:27:44.000Z","updated_at":"2025-03-12T14:40:20.000Z","dependencies_parsed_at":"2024-01-18T12:56:59.064Z","dependency_job_id":"287d129d-39fc-4d93-8308-fe0b975773aa","html_url":"https://github.com/dotkernel/dot-debugbar","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":"0.11111111111111116","last_synced_commit":"87258d0203f8451a3bd87a0bfcf790e76e4afa99"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-debugbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-debugbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-debugbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-debugbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotkernel","download_url":"https://codeload.github.com/dotkernel/dot-debugbar/tar.gz/refs/heads/1.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252648573,"owners_count":21782405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T17:34:32.102Z","updated_at":"2025-05-06T08:31:10.870Z","avatar_url":"https://github.com/dotkernel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dot-debugbar\n\nDotkernel's debug bar component\n\n\u003e dot-debugbar is a wrapper on top of [maximebf/php-debugbar](https://github.com/maximebf/php-debugbar)\n\n## Documentation\n\nDocumentation is available at: https://docs.dotkernel.org/dot-debugbar/.\n\n## Badges\n\n![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-debugbar)\n![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-debugbar/1.3.0)\n\n[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-debugbar)](https://github.com/dotkernel/dot-debugbar/issues)\n[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-debugbar)](https://github.com/dotkernel/dot-debugbar/network)\n[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-debugbar)](https://github.com/dotkernel/dot-debugbar/stargazers)\n[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-debugbar)](https://github.com/dotkernel/dot-debugbar/blob/1.0/LICENSE.md)\n\n[![Build Static](https://github.com/dotkernel/dot-debugbar/actions/workflows/continuous-integration.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-debugbar/actions/workflows/continuous-integration.yml)\n[![codecov](https://codecov.io/gh/dotkernel/dot-debugbar/graph/badge.svg?token=F0N8VWKTDW)](https://codecov.io/gh/dotkernel/dot-debugbar)\n[![docs-build](https://github.com/dotkernel/dot-debugbar/actions/workflows/docs-build.yml/badge.svg)](https://github.com/dotkernel/dot-debugbar/actions/workflows/docs-build.yml)\n[![PHPStan](https://github.com/dotkernel/dot-debugbar/actions/workflows/static-analysis.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-debugbar/actions/workflows/static-analysis.yml)\n\n## Install\n\nInstall dot-debugbar in your application by running the following command:\n\n```shell\ncomposer require dotkernel/dot-debugbar\n```\n\n## Setup\n\nOnce installed, the following components need to be registered by adding:\n\n```php\n$app-\u003epipe(\\Dot\\DebugBar\\Middleware\\DebugBarMiddleware::class);\n```\n\nto `config/pipeline.php` (preferably after `ServerUrlMiddleware::class`)\n\n```php\n\\Dot\\DebugBar\\ConfigProvider::class\n```\n\nto `config/config.php` (preferably at the beginning of the section where the `Dotkernel packages` are loaded)\n\n```php\n\\Dot\\DebugBar\\Extension\\DebugBarExtension::class\n```\n\nto `config/autoload/templates.global.php` (inside the array founder under the key `twig` =\u003e `extensions`)\n\nLocate the library's assets directory, called `assets` and copy **its contents** to your application under `public/debugbar` directory.\n\nLocate the library's config file `config/debugbar.local.php` and clone it inside your application as:\n\n* `config/autoload/debugbar.local.php.dist`\n* `config/autoload/debugbar.local.php`\n\nBy default, dot-debugbar is enabled only on the local environment, by whitelisting your local IP address in the config file, inside the array located under the `ipv4Whitelist` key.\nIf you need to enable it on other environments as well, just whitelist your public IPV4 address.\nIt can also be enabled globally, by whitelisting the string `*`.\nFinally, if you want to keep the whitelists but disable dot-debugbar, you can set `enabled` to **false**.\n\nInside the config file, you will find additional configurations under the `javascript_renderer` key.\nFor more configuration values, follow the link in the related comment block.\n\nAt this step, dot-debugbar is not displayed yet. In order to display it, you need to call the following Twig functions from your base layout:\n\n```twig\n{{ debugBarCss()|raw }}\n```\n\n(needs to be placed in the head section of the layout, where the CSS files are included)\n\n```twig\n{{ debugBarJs()|raw }}\n```\n\n(needs to be placed in the footer of the layout, where the JS files are included)\n\nIf you plan to enable dot-debugbar on production, make sure you clear the relevant cache items by deleting:\n\n* the config cache file: `data/cache/config-cache.php`\n* Twig cache directory: `data/cache/twig`\n\nAdditionally, you can check if dot-debugbar is enabled for your session by calling `debugBarEnabled()` inside a template.\nThis feature can be useful if you need to add custom logic for when dot-debugbar is enabled.\n\n## Usage\n\nOther than the data being automatically collected during a session, dot-debugbar can also be used to log messages, measure durations, debug database queries and more...\n\nWhen you need an instance of DebugBar, locate an instance of it in your application's container using:\n\n```php\n$debugBar = $container-\u003eget(\\Dot\\DebugBar\\DebugBar::class);\n```\n\nthen your factory can inject `$debugBar` as a dependency in your class.\n\nOR\n\nIf you are using [dot-annotated-services](https://github.com/dotkernel/dot-annotated-services) inject it directly in your class's constructor.\n\nOnce an instance of DebugBar has been injected in your code, you can access all its features.\nThe below examples will assume you already have an instance of DebugBar in your code, and it's callable using `$this-\u003edebugBar`.\n\n### Logging messages\n\nResults will show up in the debug bar under the `Messages` tab.\n\nLog messages (can be of any type):\n\n```php\n$this-\u003edebugBar-\u003eaddMessage(1);\n$this-\u003edebugBar-\u003eaddMessage(true);\n$this-\u003edebugBar-\u003eaddMessage('foo');\n$this-\u003edebugBar-\u003eaddMessage(['foo']);\n$this-\u003edebugBar-\u003eaddMessage(new \\stdClass());\n```\n\nLog messages and set custom label by specifying the 2nd argument (you can use any label, but `error` and `warning` use custom highlight and icons):\n\n```php\n$exception = new \\Exception('something went wrong');\n$this-\u003edebugBar-\u003eaddMessage($exception, 'error');\n$this-\u003edebugBar-\u003eaddMessage($exception-\u003egetMessage(), 'error');\n$this-\u003edebugBar-\u003eaddMessage('some warning', 'warning');\n$this-\u003edebugBar-\u003eaddMessage('custom message', 'custom');\n```\n\nAlso, clicking on a label (found on the bottom right of the debugbar) will toggle the visibility of all messages with that specific label.\n\n### Measure durations\n\nResults will show up in the debug bar under the `Timeline` tab.\n\nIn order to measure how long does it take for a piece of code to execute, do the following:\n\n```php\n$this-\u003edebugBar-\u003emeasure('long operation', function () {\n    // your code here\n});\n```\n\nOR\n\n```php\n$this-\u003edebugBar-\u003estartTimer('long operation', 'measuring long operation');\n// your code here\n$this-\u003edebugBar-\u003estopTimer('long operation');\n```\n\n### Debug Doctrine queries\n\nResults will show up in the debug bar under the `Database` tab.\n\nBy default, all queries executed in order to load a page will be logged and displayed under this tab.\nIf you submit a form that will perform a redirect, you won't see the executed CREATE/UPDATE queries unless you stack the collected data:\n\n```php\n$this-\u003edebugBar-\u003estackData();\n```\n\nThe method needs to be called after all database operations have finished AND before emitting the redirect response.\nIn this case, next to the `Memory usage` widget you'll see a dropdown that allows you to select between the previous page load (with the redirect) and the current one.\n\n### Debug Exceptions\n\nResults will show up in the debug bar under the `Exceptions` tab.\n\nBy registering `Dot\\DebugBar\\Middleware\\DebugBarMiddleware`, dot-debugbar is ready to capture Exceptions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-debugbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotkernel%2Fdot-debugbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-debugbar/lists"}