Skip to content

Commit cff32ef

Browse files
committed
feat(profiler): add cURL copy/paste to request tab
1 parent a4a0463 commit cff32ef

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* Add support for the `QUERY` HTTP method in the profiler
88
* Add support for Server-Sent Events / `EventSource` requests in the debug toolbar
99
* Add support for displaying the application runner class
10+
* Add cURL copy paste button in the Request/Response tab
1011

1112
7.3
1213
---

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,26 @@
232232
<p>No content</p>
233233
</div>
234234
{% endif %}
235+
236+
<h3>Retry command</h3>
237+
{% set curlCommand = 'curl -X ' ~ collector.method ~ ' ' ~ profile.url %}
238+
{% for name, value in collector.requestheaders %}
239+
{% set curlCommand = curlCommand ~ (' -H "%s: %s"'|format(name, value)) %}
240+
{% endfor %}
241+
{% if collector.content != '' %}
242+
{% set curlCommand = curlCommand ~ " --data '" ~ (collector.isJsonRequest ? collector.content|json_encode : collector.content) ~ "'" %}
243+
{% endif %}
244+
<div class="sf-tabs">
245+
<div class="tab">
246+
<h3 class="tab-title">cURL</h3>
247+
<div class="tab-content">
248+
<div class="card">
249+
<button class="btn btn-sm hidden" title="Copy as cURL" data-clipboard-text="{{ curlCommand }}">Copy as cURL</button>
250+
<pre class="break-long-words">{{ curlCommand }}</pre>
251+
</div>
252+
</div>
253+
</div>
254+
</div>
235255
</div>
236256
</div>
237257

0 commit comments

Comments
 (0)