如何使用 eclipse and/or netbeans 进行 symfony 自动补全

how to have symfony autocompletion with eclipse and/or netbeans

我已经用 eclipse 和 netbeans 测试了 symfony3 IDE,但我仍然无法自动完成...

这是我的控制器:

<?php

// src/OC/PlatformBundle/Controller/AdvertController.php
namespace OC\PlatformBundle\Controller;

// N'oubliez pas ce use :
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Symfony\Component\HttpFoundation\Response;

class AdvertController extends Controller
{

  public function indexAction()
  {

    $content = $this->get('templating')->render('OCPlatformBundle:Advert:index.html.twig');

    return new Response($content);

  }

}

在 Eclipse 中,我可以对 $this 进行自动完成(然后我可以选择 get),但是我从来没有获得具有自动完成功能的渲染方法..

我看了这个 Preserving auto-completion abilities with Symfony2 Dependency Injection 但我无法让它工作。

谁能帮我举个例子?

试试这个:

public function indexAction()
{
    /** @var $twig \Symfony\Bundle\TwigBundle\TwigEngine */
    $twig = $this->get('templating');
    $content = $twig->render('OCPlatformBundle:Advert:index.html.twig');;

    return new Response($content);
}

也许您需要调整评论提示,但应该可以。

但我的建议是:使用 symfony 插件获取 PhpStorm(我知道它不是免费的,但尝试一下并决定是否值得)