[Console] Added suggestions for missing packages#29865
Conversation
|
I like the idea. |
|
i'd prefer something like we did for twig: https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php i think its more straightforward to handle it in e.g. a catch-all event listener for unknown commands, opposed to tracking a list on high level (console application). |
|
I had some doubts adding it to the main application, since it is widely used as a standalone component, but I wanted the suggestions to be available for some, who started his project with a symfony/skeleton (so without the FrameworkBundle) and tries to use features, that are not installed. By the way, can you tell me, why my CI checks failed? Did I forget about something in my PR? |
|
My mistake. I confused FrameworkBundle with SensioFrameworkExtraBundle. I will rework the PR. But my other question about the CI checks is still valid :) |
268e80f to
4f0d498
Compare
|
I went with the suggestion from @ro0NL and created an event subscriber. I can always switch to a try/catch in FrameworkBundle Console Application. |
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
018f91a to
7c80043
Compare
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
56f0342 to
3bf0806
Compare
|
I improved the logic. For example, when someone has WebServerBundle and runs |
1d72a56 to
da6f7ed
Compare
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Show resolved
Hide resolved
0217579 to
8149049
Compare
|
@fabpot Done. |
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Show resolved
Hide resolved
8149049 to
d178ad5
Compare
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
d178ad5 to
7c6a2d1
Compare
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
Outdated
Show resolved
Hide resolved
7c6a2d1 to
c6b803e
Compare
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php
Outdated
Show resolved
Hide resolved
f3187ec to
ba3f404
Compare
|
Too many reviews in a short period of time and things got a little messy for a moment. I've implemented all suggestions the code, fixed the tests. The one Travis CI test that fails, failed before and I guess it has nothing to do with my code directly. The only thing left to decide is whether to put |
ba3f404 to
f1cf2f5
Compare
|
Thank you @przemyslaw-bogusz. |
f1cf2f5 to
423a54f
Compare
…myslaw-bogusz) This PR was squashed before being merged into the 4.3-dev branch (closes #29865). Discussion ---------- [Console] Added suggestions for missing packages | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Currently, when someone runs one of the most common commands, e.g. `server:run`, but does not have a required package installed, they will get a general **'There are no commands defined...'** message. This commit adds a more useful message, informing the user about a package that might be missing and suggesting a command that should be run in order to install it, e.g. `composer require symfony/web-server-bundle --dev`. Commits ------- 423a54f [Console] Added suggestions for missing packages
Currently, when someone runs one of the most common commands, e.g.
server:run, but does not have a required package installed, they will get a general 'There are no commands defined...' message.This commit adds a more useful message, informing the user about a package that might be missing and suggesting a command that should be run in order to install it, e.g.
composer require symfony/web-server-bundle --dev.