Skip to content

[FrameworkBundle] Add --method option to debug:router command #59909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

santysisi
Copy link
Contributor

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues Feature #59906
License MIT

Description

I have added a new InputOption named method to the debug:router command. This option allows developers to filter the displayed routes by HTTP method (GET, POST, PUT, DELETE, etc.) when running the command. This improvement makes it easier and more efficient to debug routes, especially in large applications. It also aligns the debug:router command with the router:match command, which already includes a similar option for filtering by HTTP method.

Changes Made

  • Added the --method option to the debug:router command.
  • Routes can now be filtered based on the HTTP method used (GET, POST, PUT, DELETE, etc.).
  • This enhances debugging capabilities and streamlines the process of working with specific route methods.

Example

Before adding the new InputOption:
php bin/console debug:router

Image

After adding the new InputOption:
php bin/console debug:router --method=GET

Image

Before adding the new InputOption with the name argument
php bin/console debug:router app_foo

Image

After adding the method InputOption with the name argument:
php bin/console debug:router app_foo --method=DELETE

Image

@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.3 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

@OskarStark OskarStark changed the title [FrameworkBundle] Add new InputOption 'method' to debug:router command [FrameworkBundle] Add --method option to debug:router command Mar 5, 2025
@santysisi santysisi force-pushed the feature_add-http-method-filter-to-debug-router branch from 2c1095c to e2d90fa Compare March 5, 2025 14:27
@santysisi santysisi force-pushed the feature_add-http-method-filter-to-debug-router branch from e2d90fa to ca61a87 Compare March 6, 2025 21:53
@santysisi santysisi requested a review from mtarld March 6, 2025 22:03
@santysisi
Copy link
Contributor Author

Hi 😃, I hope you're doing well!
I wanted to check if any further changes are needed in the PR, or if it's good to go for merging 🎉🎉🎉
Thanks a lot in advance, and I look forward to your response!

Copy link
Contributor

@mtarld mtarld left a comment

Choose a reason for hiding this comment

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

Almost good to me 😉

@santysisi santysisi force-pushed the feature_add-http-method-filter-to-debug-router branch from ca61a87 to 3d9c69d Compare March 11, 2025 13:38
Copy link
Member

@chalasr chalasr left a comment

Choose a reason for hiding this comment

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

Congrats on your great first PR to Symfony.

@santysisi
Copy link
Contributor Author

Congrats on your great first PR to Symfony.

Thank you very much, I'm very excited 😄

Comment on lines 379 to 382
if (
$route->getMethods()
&& !\in_array($method, $route->getMethods(), true)
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Symfony usually prefers one liners to ease merging

Comment on lines 142 to 145
if (
false !== stripos($routeName, $name)
&& (null === $method || !$route->getMethods() || \in_array($method, $route->getMethods(), true))
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Symfony usually prefers one liners to ease merging

@nicolas-grekas nicolas-grekas force-pushed the feature_add-http-method-filter-to-debug-router branch from 3d9c69d to 6a98d49 Compare March 13, 2025 14:16
@nicolas-grekas
Copy link
Member

Thank you @santysisi.

@nicolas-grekas nicolas-grekas merged commit 6c0058a into symfony:7.3 Mar 13, 2025
11 checks passed
@fabpot fabpot mentioned this pull request May 2, 2025
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.

7 participants