Skip to content

Conversation

@darkweak
Copy link

@darkweak darkweak commented Nov 5, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #...
License MIT

I often need to replay some requests on my application in dev mode, it's easier to generate it in the profiler Request view, copy it and paste in the terminal. It will generate the command with all given parameters/headers.

Here is a screenshot of this:
Capture d’écran 2025-11-05 à 20 31 44

I don't know if it's mandatory to write tests for that, feel free to give some advice about that.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "7.4" but it seems your PR description refers to branch "7.4 for features".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@carsonbot carsonbot changed the title feat(profiler): add cURL copy/paste to request tab feat(profiler): add cURL copy/paste to request tab Nov 5, 2025
@darkweak darkweak changed the title feat(profiler): add cURL copy/paste to request tab [WebProfiler] add cURL copy/paste to request tab Nov 5, 2025
@darkweak darkweak force-pushed the feat/profiler/add-curl-copy-paste-request branch 2 times, most recently from 8409ee2 to cff32ef Compare November 5, 2025 19:43
Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The curl command generation is flawed for several reasons:

  • it does not escape arguments properly (making it unsuitable to be used as is)
  • it uses curl -X even when it should not be used

Such logic should also be implemented in PHP in a method of the collector instead of attempting to write such complex logic in the Twig template (anyway, escaping shell arguments properly is not something we can do in Twig with only core functions and filters).

Note also that this won't make it to 7.4 (or 8.0) as we are way past the feature freeze date (which was end of September). This will be for 8.1.

@stof
Copy link
Member

stof commented Nov 5, 2025

You could see also HttpClientDataCollector which implements such "Copy as curl" as well.

@darkweak
Copy link
Author

darkweak commented Nov 5, 2025

Thank you for these feedback. I'm unsure about where to implement the collector, so where would you put the PHP class in the WebProfiler bundle codebase?

@stof
Copy link
Member

stof commented Nov 5, 2025

you don't need to implement a new collector. You need to add a new method in the RequestCollector (as you are adding that logic in the request panel, i.e. the panel associated to the RequestCollector)

@darkweak darkweak force-pushed the feat/profiler/add-curl-copy-paste-request branch from cff32ef to 0dbe5db Compare November 5, 2025 21:33
@darkweak
Copy link
Author

darkweak commented Nov 5, 2025

Okay, I have updated the RequestDataCollector class and I have something working in the template that is cleaner. 👍

@darkweak darkweak force-pushed the feat/profiler/add-curl-copy-paste-request branch 4 times, most recently from a49f4fd to f835973 Compare November 5, 2025 21:59
@darkweak darkweak force-pushed the feat/profiler/add-curl-copy-paste-request branch 2 times, most recently from 206ffa1 to f04f599 Compare November 6, 2025 07:10
@darkweak darkweak force-pushed the feat/profiler/add-curl-copy-paste-request branch from f04f599 to e4c4ff1 Compare November 6, 2025 07:14
@darkweak darkweak requested review from 94noni and stof November 6, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants