在PhpStorm,Symfony2和FOSRestBundle中找不到路由 [英] Routes not found in PhpStorm, Symfony2 and FOSRestBundle

查看:82
本文介绍了在PhpStorm,Symfony2和FOSRestBundle中找不到路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Symfony 3.2项目和FOSRestBundle上使用带有Symfony2插件的最新PhpStorm.

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

由FOSRestBundle生成的路由不会在PhpStorm中自动解析(您会获得丢失的路由"),尽管这些路由可以正常工作并显示为php bin/console debug:router

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")

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

Debug:router实际上会将其显示为get_current_doc_status,因为FOSRestBundle的Get将被前置,并且get_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.

删除自定义名称并让Symfony自己执行路由将解决(并且也可以工作),因此,该问题可能特定于自定义命名的路由+ FOSRestBundle

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

推荐答案

如果您具有新的目录结构,则 cache 文件夹位于 var 文件夹中. 因此,在 urlGenerator.php 的路径中是 var/cache/dev/appDevDebugProjectContainerUrlGenerator.php

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

这篇关于在PhpStorm,Symfony2和FOSRestBundle中找不到路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆