Question

I want to create a new Class in Symfony Eclipse. The namespace should automatically be added to the file.

I saw this here. But I can't create a 'PHP Class'. I can choose between 'PHP File' and 'Untitled PHP File'. But these guys don't automatically create the namespace.

Has this something to do with the PDT Plugin? I can't install it from the Eclipse Marketplace, because of some missing stuff..

Thank you :D

Was it helpful?

Solution

Christoph, the IDE that you reference in the video is not Eclipse, but it is phpstorm. And yes, it is a really amazing IDE. I think it is way way way better than eclipse pdt, but like many other great things in life it's not free (but you can use it for free at least for the 30 days trial), but if you don't have the money or you don't want to pay $99 for a personal license, you can use eclipse code templates to do something similar. Take a look at this tutorial.

Anyway here is an example:

  1. Window->preferences once you are in preference go PHP->Editor->Templates click on new
  2. Once you are in there type the trigger frase in the name input , symfonycontroller will do fine with this example
  3. In the description well the description hehe
  4. And in the pattern write your code template something like this i think will work for you
namespace ${namespace};

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

/**
 *
 *
 * @author ${user}
 */
 class ${class_name} extends Controller {

public function indexAction() {
    ${cursor};
}

 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top