Search code examples
symfonyurl-routingsymfony6

Symfony Route with Slash (/) in parameter not working


I have a Symfony Route configured with annotations where I want the last parameter to allow for slashes in it.

#[Route('/getFtp/{customerName}/{taskId}/{domainName}', name: 'get_ftp', requirements: ['domainName' => '.+'])]
public function index(string $customerName, string $taskId, string $domainName): Response

According to documentation https://symfony.com/doc/6.0/routing.html#slash-characters-in-route-parameters this should work.

It works for

http://mgr2.example.com/getFtp/quadramedia/abcdef/http:

but not for

http://mgr2.example.com/getFtp/quadramedia/abcdef/http:%2F

Solution

  • Using your exemple in my own project worked.

    I tryied this url http://127.0.0.1:8080/getFtp/thomas/23/http:%2F

    And then i dumped my param to be sure and got :

    enter image description here

    So, it is on your project that something is wrong.
    I expect something like an other route is matching.
    Try to define the route in yaml (or just on top of your controller) and put it on top of all the other to be completely sure that this is not working.

    By the way, i tried your case in php 8.1 and Symfony 6.2