I have installed the Symfony2 plugin for Phpstorm but I can't get the IDE to see these existing services or other injected objects. Can these be fixed somehow, so the warnings go away?
I had a similar problem and would recommend double checking the following...
As @Marcel suggested, check your Symfony2 plugin is turned on...
1.1. Settings > Symfony2 plugin
1.2. Check the paths to the these directories are correct, for some reason I had two symfony projects within a project so the default paths were not accurate
You should double check that the plugin's reference to your container XML is accurate, by default it will be "app\cache\dev\appDevDebugProjectContainer.xml" as you can see mine had to be updated and you can see the path is now "EXISTS", it said "ERROR" before
2.1. Settings > Symfony2 plugin > Container
2.2.
Then, as per @Igor's suggestion clear your cache
Finally, thanks to the @googol help, I've figured out a way to specify services definitions files in custom paths with a YML format:
You only have to create or modify the .idea/symfony2.xml
file including the following tag:
xml
<option name="containerFiles">
<list>
<container_file path="custom/path/to/your/services_definition.yml" />
</list>
</option>
You'll have to restart the PhpStorm and that's it! :)
Here you have my complete symfony2.xml
file as an example:
xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Symfony2PluginSettings">
<option name="pluginEnabled" value="true" />
<option name="twigAnnotateTemplate" value="false" />
<option name="twigAnnotateAsset" value="false" />
<option name="twigAnnotateAssetTags" value="false" />
<option name="twigAnnotateRoute" value="false" />
<option name="twigAnnotateTranslation" value="false" />
<option name="phpAnnotateTemplate" value="false" />
<option name="phpAnnotateService" value="false" />
<option name="phpAnnotateRoute" value="false" />
<option name="phpAnnotateTemplateAnnotation" value="false" />
<option name="phpAnnotateTranslation" value="false" />
<option name="phpHighlightServices" value="true" />
<option name="codeFoldingTwigRoute" value="false" />
<option name="codeFoldingTwigTemplate" value="false" />
<option name="codeFoldingTwigConstant" value="false" />
<option name="containerFiles">
<list>
<container_file path="custom/path/to/your/services_definition.yml" />
</list>
</option>
</component>
</project>
And here you have a feature request in order to include the possibility to add this custom path service definition through the plugin UI settings instead of having to edit the config file manually: https://github.com/Haehnchen/idea-php-symfony2-plugin/issues/573
Clear the cache for development environment. It should fix it if service really exists. Navigate to your project dir in terminal and type:
app/console ca:c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With