-
-
Notifications
You must be signed in to change notification settings - Fork 328
PHPStorm plugin #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for bringing that up, I had no idea it existed :) That sounds really interesting, a few remarks on the topic:
<?php
namespace PHPSTORM_META
{
$STATIC_METHOD_TYPES = [
\DI\Container::get('') => [
"" == "@",
],
\Interop\Container\ContainerInterface::get('') => [
"" == "@",
],
];
} Still the plugin can be useful, all this deserves to be documented! |
I've been used this plugin with symfony2 application, and I had access to container only in controllers (probably, better solution would be passing services into controllers as dependencies, I understand, but it seems that using container to fetch services in controllers is widespread approach in symfony2). So with symfony2-plugin I have autocompletion for core symfony2 services and my services that have to be added to symfony2 container (where tags are needed). And this plugin helped me to achieve code autocompletion for services defined in PHP-DI container.
Wow, thats interesting, I'll check this out. I will open PR to add this to docs if I have time during next week. |
👍 great And right, I forgot that in Symfony that's the documented/recommended way to use the container. So indeed it can also be useful there. |
Good discussion! Thanks for mentioning me. Just to give a bit more background about the plugin. We've built some sort of home grown application framework which uses PHP-DI. In our workflow when we work with domain layer, api endpoints or persistence it's "forbidden" to depend on container. This way we avoid service locator issues when developing our apps, everything is pure dependency injection. However there is few cases when we have to rely on container:
And of course we have Symfony app where controllers and console commands rely on container so we needed some sort of convenience there. One thing to note about this plugin: it makes big difference when refactoring things. It is not only autocompletion that helps, but also IDE uses this type information when you rename / move things around. |
@pulyaevskiy thanks for chiming in, your use cases make perfect sense to me, you seem to have something very good going on I'm always happy to learn about how people use this package ;) One thing that could be considered for improving the plugin (but of course requires time to implement it): make it work only for |
Technically it already works with pretty much any container (and not only container) which uses Though I agree that constraining it to |
Was fixed in #334, it's online: http://php-di.org/doc/ide-integration.html Awesome! |
Awesome, thanks for adding the documentation on it. There's also support for the |
👍 great! |
Hi.
A few days ago I found PHPStorm plugin that makes code completion work for services fetched from container: pulyaevskiy/phpstorm-phpdi. It's pretty simple, but does it's job well.
No more _@_var annotations needed, it just works (if you using php5.5 syntax for defining services).
I find it very useful, so maybe it is worth to be added to the documentation?
It is not a PR adding link to the docs cause I'm not sure it is a good idea. Maybe @pulyaevskiy should give his agreement at first? It is published under MIT license, but I'm not good at software license types.
The text was updated successfully, but these errors were encountered: