1313
1414use Symfony \Component \Console \Input \InputArgument ;
1515use Symfony \Component \Console \Input \InputInterface ;
16+ use Symfony \Component \Console \Input \InputOption ;
1617use Symfony \Component \Console \Output \OutputInterface ;
1718use Symfony \Component \Console \Input \ArrayInput ;
1819use Symfony \Component \Routing \RouterInterface ;
@@ -50,12 +51,16 @@ protected function configure()
5051 ->setName ('router:match ' )
5152 ->setDefinition (array (
5253 new InputArgument ('path_info ' , InputArgument::REQUIRED , 'A path info ' ),
54+ new InputOption ('method ' , null , InputOption::VALUE_REQUIRED , 'Sets the HTTP method ' , 'GET ' ),
55+ new InputOption ('host ' , null , InputOption::VALUE_REQUIRED , 'Sets the HTTP host ' , 'localhost ' ),
5356 ))
5457 ->setDescription ('Helps debug routes by simulating a path info match ' )
5558 ->setHelp (<<<EOF
5659The <info>%command.name%</info> simulates a path info match:
5760
5861 <info>php %command.full_name% /foo</info>
62+ or
63+ <info>php %command.full_name% /foo --method POST --host symfony.com</info>
5964
6065EOF
6166 )
@@ -68,7 +73,11 @@ protected function configure()
6873 protected function execute (InputInterface $ input , OutputInterface $ output )
6974 {
7075 $ router = $ this ->getContainer ()->get ('router ' );
71- $ matcher = new TraceableUrlMatcher ($ router ->getRouteCollection (), $ router ->getContext ());
76+ $ context = $ router ->getContext ();
77+ $ context ->setMethod ($ input ->getOption ('method ' ));
78+ $ context ->setHost ($ input ->getOption ('host ' ));
79+
80+ $ matcher = new TraceableUrlMatcher ($ router ->getRouteCollection (), $ context );
7281
7382 $ traces = $ matcher ->getTraces ($ input ->getArgument ('path_info ' ));
7483
0 commit comments