Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHPStorm][annotations] Missing route #828

Closed
traczewskim opened this issue Dec 1, 2016 · 8 comments
Closed

[PHPStorm][annotations] Missing route #828

traczewskim opened this issue Dec 1, 2016 · 8 comments

Comments

@traczewskim
Copy link

I have a problem with "Missing route" exception in PHPStorm. I've already created support ticket in JetBrains and after couple of e-mail they suggested to contact with plugin author. Problem is that with no reason PHPStorm doesn't recognize some of the router. Some of theme are find ok, but other are mark as missing route. In prod, dev, test environment everything works just fine. Problem is only with finding route in PHPStorm itself. Here is an example of code that shows this issue

screenshot_3

@Kearny
Copy link

Kearny commented Dec 7, 2016

Just to say that I have the exact same issue.

@flavienaudin
Copy link

Same problem here, something like one week ago, "missing route" starting to appear while they exist and the completion was working before. All routes are not concerned and I didn't manage to identidy the common denominator.
Thank for the help

@dspiegel
Copy link

dspiegel commented Feb 9, 2017

I ran into same problem. Noticed that only specific controller were missing routes.
After comparing working vs. not working controller, I found and fixed the following use statement difference:

Replaced use Symfony\Component\Routing\Annotation\Route;
With use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

The issue was resolved following the change. Must have selected wrong class when controller was created.

Symfony had no issues working with either one of the classes, but this plugin does not work unless using FrameworkExtraBundle Route class.

Maybe this will help someone else.

  • Dave

@Haehnchen
Copy link
Owner

@dspiegel thx use Symfony\Component\Routing\Annotation\Route as BaseRoute of FrameworkExtraBundle was indeed not supported

@mtraczewski
Copy link

@dspiegel Great investigation! Great job! Your solution works perfect.

@Haehnchen
Copy link
Owner

both "@route" are supported since Feb, closing

@alexkunin
Copy link

PHPStorm 2018.3 ("Build #PS-183.4284.150, built on November 21, 2018"), Symfony 4.1.6, pretty small project based on symfony/skeleton with basic login form copy-pasted from Symfony docs. Issue is there again:

  • having use Symfony\Component\Routing\Annotation\Route causes "Missing route"
  • switching to use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route fixes "Missing route", but this annotation class is marked as @deprecated since version 5.2

@abarke
Copy link

abarke commented Jul 3, 2019

Symfony Plugin v0.17.172
I have the same issue now with PhpStorm 2018.3.4 Build #PS-183.5429.47, built on February 8, 2019

use Symfony\Component\Routing\Annotation\Route;
###
/** @Route("/forum/login", name="app_forum_login", methods={"GET", "HEAD"}
###
$forumUrl = $this->generateUrl('app_forum_login', [], UrlGeneratorInterface::ABSOLUTE_URL);

However it only applies to some files and not others... so I investigated the root cause and it seems that our custom DocBlock @user annotation was causing the issue. As soon as I remove it, the routes defined in that file are found as expected. Wierd! Seems it must be preventing the Plugin from inspecting the file.

Anyway here is an example of the culprit!

<?php
/**
 * @user
 */
declare(strict_types=1);
namespace App\Controller\Forum;
/** If you move it here, the routes are found! */

As the @user annotation is not a PHPDoc or Pear Standard annotation we will remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants