2
votes

I'm using latest version of PHPStorm 10 and want to use annotations for my Symfony 2.8.1 routes. I want to use PHPStorm's autocomplete feature to autocomplete my routes in twig files, but they are autocompleted wrong. I'm using both Symfony2 plugin and PHP Annotations.

Routing file

#app/config/routing.yml
ParkResortBundle:
    resource: "@ParkResortBundle/Controller"
    prefix: /
    type: annotation

My controller with one route

namespace ParkResortBundle\Controller;
class DefaultController extends Controller
{
    /**
     * @return Response
     * @Route("/")
     */
    public function indexAction()
    {
        return $this->render('ParkResortBundle:Pages:firstpage.html.twig');
    }
}

This should normally generate park_resort_default_index but instead it generates parkresort_default_index and my PHPStorm finds and autocompletes it with the underscore. I've also ran debug:router to confirm and it indeed finds the route and it does work without the underscore. But I want it with the underscore.

Even in the docs it says:

sensio_blog_post_index is the route for SensioBlogBundle's Postcontroller index action. It puts an underscore in between the camelcase capital letters.

What did I do wrong?

1
PHPStorm uses the appDevUrlGenerator.php located in the dev cache folder to autocomplete routes. Check it to make sure symfony generates correct route names. #Settings > Other settings > Symfony plugin - Path to urlGenerator.phpFracsi
That field has 'var/cache/dev/appDevUrlGenerator.php' in itGeorge Irimiciuc
Check it's contents. Also you can name your routes to almost anything. It's good practice to name them explicitly. @Route("/", name="some_route_name")Fracsi
The generator contains the routes without the undescore. Why are they generated like that? The docs say that they should contain underscores by default.George Irimiciuc
"I know, but I cannot use PHPStorm's autocomplete feature." It's not PhpStorm itself that provides Symfony integration/support here -- it's all handled by Symfony support plugin. I personally do use Symfony and this plugin .. but maybe you are still missing "PHP Annotation" plugin (that works with annotations)?LazyOne

1 Answers

1
votes

I will add your cases. see external issues

https://github.com/Haehnchen/idea-php-symfony2-plugin/issues/673

EDIT: fixed in version "0.11.109"