A
A
Anton Medvedev2012-08-03 23:17:10
symfony
Anton Medvedev, 2012-08-03 23:17:10

What to do with code complete in Symfony2?

I work in PhpStorm and I'm used to being able to codecomplete, however symphony uses DI with $this->get('...')

What do you do with it? I see several solutions:
1. Do nothing. This option does not suit me.
2. Add along the construction code: /** var $em \Symfony\… */ This option is also not good, you need to write too much.
3. Separate into a separate class with static getters with dockblocks.

Which option are you using? Perhaps there is a better solution?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
B
BoShurik, 2012-08-03
@BoShurik

You can extend the controller class by adding getters for frequently used services, by analogy with
getRequest()and getDoctrine()
In the services themselves, I try not to pass the container, so there are no problems with this. But I have not yet decided
how best to add an autocomplete for myself.$this->getDoctrine()->getManager()->getRepository('...')

D
denver, 2012-08-04
@denver

Asked Lukas (lsmith) about the same, answered that they already sent jetbrains some xml describing all returned classes with a request to make support for such dynamic typing. Probably it is supposed to describe also the services in similar xml. Those. some process is going on, but of course in 201x to invent DI without autocomplete support (and be proud of it) is in the spirit of Fabien. For now, we use /** var … */s everywhere and private getters here and there. But not a separate class with static ones, this also violates the principles of IoC.

F
faost, 2013-05-15
@faost

Support in phpStorm: plugins.jetbrains.com/plugin/?phpStorm&pluginId=7219

F
faost, 2012-08-11
@faost

When tired of writing

/** @var ... */

Switched to Eclipse, there is a wonderful plugin symfony.dubture.com

A
Andrey, 2012-08-15
@VladimirAndreev

netbeans 7.2 can do this...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question