symfony: Routes containing a period/dot don't work
| Q | A |
|---|---|
| Bug report? | yes/no |
| Feature request? | yes/no |
| BC Break report? | yes/no |
| RFC? | yes/no |
| Symfony version | 4.0.0 |
I have created my routing using the following annotation:
/**
* @Route("/project/{id}/{file}.{extension}", methods={"GET"}, name="get_project_image")
*/
When I run php bin/console debug:router, it shows my route:
get_project_image GET ANY ANY /api/project/{id}/{file}.{extension}
However, when I navigate towards the URL, it gives me the following error (the “/api” in front of the URL is because I have another route on my controller":
No route found for "GET /api/project/1/test.xml"
This is very confusing to me, this should work according to the Symfony docs.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 23 (12 by maintainers)
@TomasVotruba
router.php:
Dump that into your public directory and when you start the php server append it with
router.phpas inphp -S localhost:8000 router.phpThis is a bug with php’ built in server so the issue is correctly closed. The problem is that the server is detecting the route as a static file. I had the issue with /sitemap.xml which was dynamically generated and you have the same issue with groups.json
I have come across this issue and believe its the period in the actual route. With a basic controller(provided below) router:match works on both /test/example-value and /test/example.value however a http request to example.value will return a 404.
If i come across anything further I will add some notes.
Additional: I tested this using PHP’s built in server and it does not match, using nginx docker it works fine. This leads me to believe this issue is with php’ server. I am leaving it there as I have a work around; just adding notes for anyone else that comes along with this issue.