Skip to content

Commit 965cc6b

Browse files
authored
Merge pull request #6 from php-debugbar/debugbar-v3
Update for debugbar v3
2 parents 3e1f220 + aaec772 commit 965cc6b

7 files changed

Lines changed: 48 additions & 37 deletions

File tree

.github/workflows/run-integration.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
pull_request:
88
branches:
99
- "*"
10-
schedule:
11-
- cron: '0 0 * * *'
1210

1311
jobs:
1412
php-tests:
@@ -19,7 +17,7 @@ jobs:
1917

2018
strategy:
2119
matrix:
22-
php: [8.5, 8.4, 8.3, 8.2, 8.1]
20+
php: [8.5, 8.4, 8.3, 8.2]
2321

2422
name: PHP${{ matrix.php }}
2523

.github/workflows/run-screenshots.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
pull_request:
88
branches:
99
- "*"
10-
schedule:
11-
- cron: '0 0 * * *'
1210

1311
jobs:
1412
php-tests:

.github/workflows/run-tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
pull_request:
88
branches:
99
- "*"
10-
schedule:
11-
- cron: '0 0 * * *'
1210

1311
jobs:
1412
php-tests:
@@ -19,7 +17,7 @@ jobs:
1917

2018
strategy:
2119
matrix:
22-
php: [8.5, 8.4, 8.3, 8.2, 8.1]
20+
php: [8.5, 8.4, 8.3, 8.2]
2321

2422
name: PHP${{ matrix.php }}
2523

composer.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^8.1",
21-
"php-debugbar/php-debugbar": "^2.0",
20+
"php": "^8.2",
21+
"php-debugbar/php-debugbar": "^3",
2222
"doctrine/orm": "^2.10|^3.0",
23-
"doctrine/dbal": "^3.6|^4",
24-
"symfony/var-exporter": "^6.4|^7",
25-
"symfony/dom-crawler": "^6.4|^7",
26-
"symfony/browser-kit": "^6.4|^7"
23+
"doctrine/dbal": "^3.6|^4"
2724
},
2825
"require-dev": {
26+
"symfony/var-exporter": "^6.4|^7",
27+
"symfony/dom-crawler": "^6.4|^7",
28+
"symfony/browser-kit": "^6.4|^7",
2929
"phpunit/phpunit": "^10",
3030
"symfony/panther": "^1|^2.1",
3131
"dbrekelmans/bdi": "^1"
@@ -55,7 +55,8 @@
5555
},
5656
"extra": {
5757
"branch-alias": {
58-
"dev-master": "2.0-dev"
58+
"dev-master": "3.0-dev"
5959
}
60-
}
60+
},
61+
"minimum-stability": "beta"
6162
}

demo/assets.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/** @var \DebugBar\DebugBar $debugbar */
6+
/** @var \DebugBar\JavascriptRenderer $debugbarRenderer */
7+
8+
//Disable session caching
9+
session_cache_limiter('');
10+
11+
include 'bootstrap.php';
12+
13+
$openHandler = new DebugBar\AssetHandler($debugbar);
14+
$openHandler->handle($_GET);

demo/bootstrap.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
$debugbar = new StandardDebugBar();
1111
$debugbarRenderer = $debugbar->getJavascriptRenderer()
12-
->setBaseUrl('../src/DebugBar/Resources')
12+
->setAssetHandlerUrl('assets.php')
1313
->setAjaxHandlerEnableTab(true)
1414
->setHideEmptyTabs(true)
15-
->setEnableJqueryNoConflict(false)
1615
->setTheme($_GET['theme'] ?? 'auto');
1716

17+
1818
//
1919
// create a writable profiles folder in the demo directory to uncomment the following lines
2020
//
@@ -27,24 +27,26 @@ function render_demo_page(?Closure $callback = null)
2727
global $debugbarRenderer;
2828
?>
2929
<html>
30-
<head>
31-
<?php echo $debugbarRenderer->renderHead() ?>
32-
<script type="text/javascript">
33-
$(function() {
34-
$('.ajax').click(function() {
35-
$.get(this.href, function(data) {
36-
$('#ajax-result').html(data);
37-
});
38-
return false;
30+
<script type="text/javascript" nonce="demo">
31+
document.addEventListener('DOMContentLoaded', function() {
32+
document.querySelectorAll('.ajax').forEach(function(el) {
33+
el.addEventListener('click', function(event) {
34+
event.preventDefault();
35+
fetch(this.href)
36+
.then(response => response.text())
37+
.then(data => {
38+
document.getElementById('ajax-result').innerHTML = data;
39+
});
3940
});
4041
});
41-
</script>
42-
</head>
42+
});
43+
</script>
4344
<body>
4445
<h1>DebugBar Demo</h1>
4546
<p>DebugBar at the bottom of the page</p>
4647
<?php if ($callback) $callback(); ?>
4748
<?php
49+
echo $debugbarRenderer->renderHead();
4850
echo $debugbarRenderer->render();
4951
?>
5052
</body>

src/DoctrineCollector.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function setDebugStack(DebugBarSQLMiddleware $debugStack): void
5757
*
5858
* @param bool $enabled
5959
*/
60-
public function setDurationBackground($enabled)
60+
public function setDurationBackground(bool $enabled): void
6161
{
6262
$this->durationBackground = $enabled;
6363
}
@@ -67,15 +67,15 @@ public function setDurationBackground($enabled)
6767
*
6868
* @param int|float $threshold miliseconds value
6969
*/
70-
public function setSlowThreshold($threshold)
70+
public function setSlowThreshold(int|float $threshold): void
7171
{
7272
$this->slowThreshold = $threshold / 1000;
7373
}
7474

7575
/**
7676
* @return array
7777
*/
78-
public function collect()
78+
public function collect(): array
7979
{
8080
$queries = array();
8181
$nb_statements = 0;
@@ -85,7 +85,7 @@ public function collect()
8585
'sql' => $q['sql'],
8686
'params' => (object) $this->getParameters($q['params'] ?? []),
8787
'duration' => $q['executionMS'],
88-
'duration_str' => $this->formatDuration($q['executionMS']),
88+
'duration_str' => $this->getDataFormatter()->formatDuration($q['executionMS']),
8989
'type' => $q['type'] ?? null,
9090
'slow' => $this->slowThreshold && $this->slowThreshold <= $q['executionMS'],
9191
);
@@ -114,7 +114,7 @@ public function collect()
114114
'count' => count($queries),
115115
'nb_statements' => $nb_statements,
116116
'accumulated_duration' => $totalExecTime,
117-
'accumulated_duration_str' => $this->formatDuration($totalExecTime),
117+
'accumulated_duration_str' => $this->getDataFormatter()->formatDuration($totalExecTime),
118118
'statements' => $queries
119119
);
120120
}
@@ -145,15 +145,15 @@ public function getParameters($params) : array
145145
/**
146146
* @return string
147147
*/
148-
public function getName()
148+
public function getName(): string
149149
{
150150
return 'doctrine';
151151
}
152152

153153
/**
154154
* @return array
155155
*/
156-
public function getWidgets()
156+
public function getWidgets(): array
157157
{
158158
return array(
159159
"database" => array(
@@ -172,7 +172,7 @@ public function getWidgets()
172172
/**
173173
* @return array
174174
*/
175-
public function getAssets()
175+
public function getAssets(): array
176176
{
177177
return array(
178178
'css' => 'widgets/sqlqueries/widget.css',

0 commit comments

Comments
 (0)