[11.x] Display migrate and db commands in their namespace #51941
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the problem?
Laravel artisan is based on Symfony console component, in which commands without ":" (colons) belong to global namespace. Thus, when listing commands in console, migrate is displayed in global namespace and other migrate:* commands are displayed in migrate namespace. There are 2 cases:
php artisan
, we'll see migrate on the top of the list but must scroll down to see other migrate:* commands.php artisan list migrate
, we'll see only migrate:* commands and can not see migrate.I mean same categorized commands (interacting with same things) like migrate commands may be displayed in different namespaces. It's a bit unconvenient, isn't it?
Click to see the current display
Solution
I think it's reasonable to display migrate command in "migrate" namespace. Of course, we can use use something like "grep" on Unix-like system but there are still tricks to do it natively.
In this PR, I rename migrate command to migrate:run and set an alias for it. Then, all migrate:* commands are now displayed together. And as you can see, migrate:run is still informative (Run the database migrations). Finally, it's total backward compatibility because "php artisan migrate" still works as it does. I do the exact same thing for db command.
Quick overview