Skip to content

Commit 84c261d

Browse files
authored
Merge pull request #2587 from atishamte/routes
Better debug routes
2 parents d0f6638 + 733bdd9 commit 84c261d

3 files changed

Lines changed: 46 additions & 17 deletions

File tree

system/Commands/Utilities/Routes.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,24 @@ public function run(array $params)
124124
{
125125
$routes = $collection->getRoutes($method);
126126

127-
foreach ($routes as $from => $to)
127+
foreach ($routes as $route => $handler)
128128
{
129129
// filter for strings, as callbacks aren't displayable
130-
if (is_string($to))
130+
if(is_string($handler))
131131
{
132132
$tbody[] = [
133-
$from,
134-
$method,
135-
$to,
133+
strtoupper($method),
134+
$route,
135+
$handler,
136136
];
137137
}
138138
}
139139
}
140140

141141
$thead = [
142-
'Route',
143142
'Method',
144-
'Command',
143+
'Route',
144+
'Handler',
145145
];
146146

147147
CLI::table($tbody, $thead);

system/Debug/Toolbar/Collectors/Routes.php

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,38 @@ public function display(): array
132132
];
133133

134134
/*
135-
* Defined Routes
136-
*/
137-
$rawRoutes = $rawRoutes->getRoutes();
135+
* Defined Routes
136+
*/
138137
$routes = [];
138+
$methods = [
139+
'get',
140+
'head',
141+
'post',
142+
'patch',
143+
'put',
144+
'delete',
145+
'options',
146+
'trace',
147+
'connect',
148+
'cli',
149+
];
139150

140-
foreach ($rawRoutes as $from => $to)
151+
foreach ($methods as $method)
141152
{
142-
$routes[] = [
143-
'from' => $from,
144-
'to' => $to,
145-
];
153+
$raw = $rawRoutes->getRoutes($method);
154+
155+
foreach ($raw as $route => $handler)
156+
{
157+
// filter for strings, as callbacks aren't displayable
158+
if (is_string($handler))
159+
{
160+
$routes[] = [
161+
'method' => strtoupper($method),
162+
'route' => $route,
163+
'handler' => $handler,
164+
];
165+
}
166+
}
146167
}
147168

148169
return [

system/Debug/Toolbar/Views/_routes.tpl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@
3333
<h3>Defined Routes</h3>
3434

3535
<table>
36+
<thead>
37+
<tr>
38+
<th>Method</th>
39+
<th>Route</th>
40+
<th>Handler</th>
41+
</tr>
42+
</thead>
3643
<tbody>
3744
{routes}
3845
<tr>
39-
<td>{from}</td>
40-
<td>{to}</td>
46+
<td>{method}</td>
47+
<td>{route}</td>
48+
<td>{handler}</td>
4149
</tr>
4250
{/routes}
4351
</tbody>

0 commit comments

Comments
 (0)