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
Suggest packages on missing autowiring aliases #30521
Comments
I would like to work on this issue @nicolas-grekas how do you suggest implementing the desired functionality in terms of which packages interfaces should be suggested. Should we extract all possible interfaces from the packages that exist in the Symfony recipes repository or some more robust way of doing that? |
From what I read, these two messages are found:
I think we could add a static class in the DI component that would hard-code a few packages - let's start with only the ones mentionned in the description and see later if/how to grow the list? |
Okay I'm working on a PR for this feature. |
I have a qustion about how to check if flex is installed in a symfony application. I tried to check if flex class exists ( Does anybody have an idea how this can be solved? |
I think that's the best solution actually :) |
@moynzzz Are you still working on it ? |
@Simperfit Yes, I am. Sorry for the delay I was a little busy last month. |
When I use a type-hint for an interface that is not installed, autowiring fails with a generic message, e.g.:
Cannot autowire argument $client of "App\Controller\HelloController::index()": argument "$responseFactory" of method "Symfony\Component\HttpClient\Psr18Client::__construct()" has type "Psr\Http\Message\ResponseFactoryInterface" but this class was not found.
But in this example, we could suggest a solution:
compose require nyholm/psr7
will install recipes for the interface. Maybe we could display this as a suggestion when we detect that flex is installed? We would do this for packages with official recipes only to reduce the scope.Another example is
Cannot determine controller argument for "App\Controller\HelloController::index()": the $client argument is type-hinted with the non-existent class or interface: "Psr\Http\Client\ClientInterface".
whenpsr/http-client
is missing.The text was updated successfully, but these errors were encountered: