Question

I'm trying PHPStorm and have trouble with its code completion. I write project with Silex framework and faced PHPStorm's lack of code completion for Silex dependency injection container. For example, it doesnt codecomplete $app['twig']-> or $app['db']-> or any other service. The only way solution I've found is to do smth like this

$db = $app['db'];
/** @var $db \Doctrine\DBAL\Connection */
$db->....

And then PHPStorm will do code completion. Services are registered using ServiceProvider interface. Is there a way to make PHPStorm do code completion in such cases without additional vars and comments?

Was it helpful?

Solution

As far as I'm aware, this is currently not possible, however, there is currently work going on to add support for generic factory patterns, see this issue on their issue-tracker:

http://youtrack.jetbrains.com/issue/WI-6027

The PhpStorm developers welcome new feature requests on their issue tracker and are quite responsive. So you may file a feature request

Also, this may be related to your question: http://youtrack.jetbrains.com/issue/WI-5304

OTHER TIPS

Here's a plugin for PHPStorm / Intellij IDEA: https://plugins.jetbrains.com/plugin/7809?pr=

Didn't tried it yet, but looks promising...

Edit: Just gave it a quick shot, and it looks really cool and simple to set up:

  • Install the plugin via the IDE plugin manager

  • Add the following dependency:

"require": {
    "sorien/silex-pimple-dumper": "~1.0"
}
  • Register the provider:

    $app->register(new Sorien\Provider\PimpleDumpProvider());

And you are done.

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