-->

Routes not found in PhpStorm, Symfony2 and FOSRest

2019-08-06 05:44发布

问题:

I'm using latest PhpStorm with the Symfony2 plugin on a Symfony 3.2 project and FOSRestBundle.

The routes generated by the FOSRestBundle don't get resolved automatically in PhpStorm (you get "missing route") although the routes work fine and show up with php bin/console debug:router

Has anyone found a trick to get them to show as good routes? It's not blocking me from anything, just a visual thing.

Update: Appears to be working except for explicitly named routes. I had forgotten (or not thought it was relevant) that my route was defined explicitly, so:

@Rest\Route("/doc/{id}/status", name="_current_doc_status")

Debug:router would actually show this as get_current_doc_status because FOSRestBundle's Get would be prepended, and get_current_doc_status would work in the code just fine, it's just resolving it.

Removing the custom name and letting Symfony do the route itself will resolve (and also work), so the issue may be specific to custom named routes + FOSRestBundle

回答1:

if you have new directory structure, the folder cache is in var folder. So in Path to urlGenerator.php is var/cache/dev/appDevDebugProjectContainerUrlGenerator.php