debugbar.html.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. /**
  3. * @var array $profiler [
  4. * '@timestamp' => (new DateTimeImmutable())->format('c'),
  5. * 'log.level' => 'debug',
  6. * 'id' => $request->getAttribute('request_id', 'unknown'),
  7. * 'event.duration' => $duration,
  8. * 'metrics' => [
  9. * 'memory.usage' => $this->convertMemory(memory_get_usage(true)),
  10. * 'memory.peak' => $this->convertMemory(memory_get_peak_usage(true)),
  11. * 'load_time.ms' => $duration * 1000,
  12. * 'load_time.s' => number_format($duration, 3),
  13. * ],
  14. * 'http.request' => [
  15. * 'method' => $request->getMethod(),
  16. * 'url' => $request->getUri()->__toString(),
  17. * 'path' => $request->getUri()->getPath(),
  18. * 'body' => $request->getBody()->getContents(),
  19. * 'headers' => $request->getHeaders(),
  20. * 'query' => $request->getQueryParams(),
  21. * 'post' => $request->getParsedBody() ?? [],
  22. * 'cookies' => $request->getCookieParams(),
  23. * 'protocol' => $request->getProtocolVersion(),
  24. * 'server' => $request->getServerParams(),
  25. * ],
  26. * ]
  27. */
  28. ?>
  29. <style>
  30. .__michel_debug_navbar {
  31. background-color: #1e232d;
  32. position: fixed;
  33. right: 0;
  34. bottom: 0;
  35. width: 100%;
  36. display: flex;
  37. height: 40px;
  38. font-family: Inter, sans-serif;
  39. white-space: nowrap;
  40. }
  41. .__michel_debug_navbar a {
  42. color: rgb(166, 223, 239);
  43. display: block;
  44. text-align: center;
  45. padding: 12px 14px;
  46. text-decoration: none;
  47. font-size: 12px;
  48. }
  49. .__michel_debug_navbar a:hover {
  50. background-color: #07193e;
  51. }
  52. .__michel_debug_navbar a:hover > .__michel_debug_value {
  53. transform: scale(1.05);
  54. }
  55. .__michel_debug_value {
  56. font-weight: bold;
  57. font-size: 11px;
  58. color: #ececec;
  59. display: inline-block;
  60. }
  61. .__michel_dropup {
  62. position: relative;
  63. display: inline-block;
  64. }
  65. .__michel_dropup-content {
  66. font-size: 12px;
  67. display: none;
  68. position: absolute;
  69. background-color: #1e232d;
  70. max-width: 450px;
  71. max-height: 480px;
  72. bottom: 40px;
  73. overflow: hidden;
  74. overflow-y: auto;
  75. padding: 10px;
  76. z-index: 100000;
  77. vertical-align: baseline;
  78. letter-spacing: normal;
  79. white-space: nowrap;
  80. }
  81. .__michel_dropup-content a:hover {
  82. background-color: inherit;
  83. }
  84. .__michel_dropup:hover .__michel_dropup-content {
  85. display: block;
  86. }
  87. .__michel_table {
  88. border-collapse: collapse;
  89. border-spacing: 0;
  90. width: 100%;
  91. border: 0px;
  92. }
  93. .__michel_table th, td {
  94. text-align: left;
  95. padding: 6px;
  96. }
  97. .__michel_label {
  98. padding: 4px;
  99. }
  100. .__michel_label_success {
  101. background-color: #04AA6D;
  102. }
  103. /* Green */
  104. .__michel_label_info {
  105. background-color: #2196F3;
  106. }
  107. /* Blue */
  108. .__michel_label_warning {
  109. background-color: #ff9800;
  110. }
  111. /* Orange */
  112. .__michel_label_danger {
  113. background-color: #f44336;
  114. }
  115. /* Red */
  116. .__michel_label_other {
  117. background-color: #e7e7e7;
  118. color: black;
  119. }
  120. /* Gray */
  121. </style>
  122. <div class="__michel_debug_navbar">
  123. <div class="__michel_dropup">
  124. <a href="#response">
  125. <?php if ($profiler['__response_code'] >= 200 && $profiler['__response_code'] < 300) : ?>
  126. 🚦 <span class="__michel_label __michel_label_success"><span
  127. class="__michel_debug_value"><?php echo $profiler['__response_code'] ?></span></span>
  128. <?php elseif ($profiler['__response_code'] >= 300 && $profiler['__response_code'] < 400) : ?>
  129. 🚦 <span class="__michel_label __michel_label_info"><span
  130. class="__michel_debug_value"><?php echo $profiler['__response_code'] ?></span></span>
  131. <?php elseif ($profiler['__response_code'] >= 400 && $profiler['__response_code'] < 500) : ?>
  132. 🚦 <span class="__michel_label __michel_label_warning"><span
  133. class="__michel_debug_value"><?php echo $profiler['__response_code'] ?></span></span>
  134. <?php else : ?>
  135. 🚦 <span class="__michel_label __michel_label_danger"><span
  136. class="__michel_debug_value"><?php echo $profiler['__response_code'] ?></span></span>
  137. <?php endif; ?>
  138. </a>
  139. <div class="__michel_dropup-content">
  140. <table class="__michel_table">
  141. <tr>
  142. <td>HTTP status <Ver></Ver></td>
  143. <td class="__michel_debug_value" title="<?php echo $profiler['__response_code'] ?>"><?php echo $profiler['__response_code'] ?></td>
  144. </tr>
  145. <?php if (isset($profiler['__controller'])) : ?>
  146. <tr>
  147. <td>Controller</td>
  148. <td class="__michel_debug_value" title="<?php echo $profiler['__controller'] ?>"><?php echo $profiler['__controller'] ?></td>
  149. </tr>
  150. <?php endif; ?>
  151. <?php if (isset($profiler['__route_name'])) : ?>
  152. <tr>
  153. <td>Route name</td>
  154. <td class="__michel_debug_value" title="<?php echo $profiler['__route_name'] ?>"><?php echo $profiler['__route_name'] ?></td>
  155. </tr>
  156. <?php endif; ?>
  157. </table>
  158. </div>
  159. </div>
  160. <a href="#time">
  161. 🕒 [REQ] <span class="__michel_debug_value"><?php echo $profiler['metrics']['load_time.ms'] ?> ms</span>
  162. </a>
  163. <a href="#memory">
  164. 💾 [MEM] <span class="__michel_debug_value"><?php echo $profiler['metrics']['memory.peak.human'] ?></span>
  165. </a>
  166. <a href="#request">
  167. 🌐 [METHOD] <span class="__michel_debug_value"><?php echo $profiler['http.request']['method'] ?></span>
  168. </a>
  169. <a href="#env">
  170. 🛠️ [ENV] <span class="__michel_debug_value"><?php echo strtoupper($profiler['environment']) ?></span>
  171. </a>
  172. <div class="__michel_dropup">
  173. <a href="#">
  174. 🐘 [PHP] <span class="__michel_debug_value"><?php echo $profiler['php_version'] ?></span>
  175. </a>
  176. <div class="__michel_dropup-content">
  177. <table class="__michel_table">
  178. <tr>
  179. <td>PHP Version</td>
  180. <td class="__michel_debug_value"
  181. title="<?php echo $profiler['php_version'] ?>"><?php echo $profiler['php_version'] ?></td>
  182. </tr>
  183. <tr>
  184. <td>PHP Extensions</td>
  185. <td class="__michel_debug_value"
  186. title="<?php echo $profiler['php_extensions'] ?>"><?php echo $profiler['php_extensions'] ?></td>
  187. </tr>
  188. <tr>
  189. <td>PHP SAPI</td>
  190. <td class="__michel_debug_value"
  191. title="<?php echo $profiler['php_sapi'] ?>"><?php echo $profiler['php_sapi'] ?></td>
  192. </tr>
  193. <tr>
  194. <td>PHP Memory Limit</td>
  195. <td class="__michel_debug_value"
  196. title="<?php echo $profiler['php_memory_limit'] ?>"><?php echo $profiler['php_memory_limit'] ?></td>
  197. </tr>
  198. <tr>
  199. <td>PHP Timezone</td>
  200. <td class="__michel_debug_value"
  201. title="<?php echo $profiler['php_timezone'] ?>"><?php echo $profiler['php_timezone'] ?></td>
  202. </tr>
  203. </table>
  204. </div>
  205. </div>
  206. <?php if (isset($profiler['__middlewares_executed'])) : ?>
  207. <div class="__michel_dropup">
  208. <a href="#" title="Middlewares executed">
  209. 🔀 [MID] <span class="__michel_debug_value"><?php echo count($profiler['__middlewares_executed']) ?></span>
  210. </a>
  211. <div class="__michel_dropup-content">
  212. <table class="__michel_table">
  213. <?php foreach ($profiler['__middlewares_executed'] as $index => $middleware) : ?>
  214. <tr>
  215. <td>
  216. <span class="__michel_debug_value"><?php echo sprintf('%s. %s', $index + 1, $middleware) ?></span>
  217. </td>
  218. </tr>
  219. <?php endforeach; ?>
  220. </table>
  221. </div>
  222. </div>
  223. <?php endif; ?>
  224. </div>