How Does Composer Resolve The `dumpautoload` command?
Using Composer version 1.8.6 2019-06-11 15:03:05
the dumpautoload
command works with all the following variations
composer dump-autoload
composer dumpautoload
composer dumpautoloa
composer dumpautolo
composer dumpautol
composer dumpauto
composer dumpaut
composer dumpau
composer dumpa
composer dump
composer dum
composer du
Until composer d
which throws
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "d" is ambiguous (depends, dump-autoload and 1 more).
How are the commands resolved? I understand that dumpautoload
is set as an alias to dump-autoload
in composer source here
class DumpAutoloadCommand extends BaseCommand
{
protected function configure()
{
$this->setName('dump-autoload')->setAliases(array('dumpautoload'))
and setAliases
in the composer/RootPackage.php
source here only assign the aliases to the private $aliases;
property
public function setAliases(array $aliases)
{
$this->aliases = $aliases;
}
But how are the other variations resolved?
Answer
Composer builds up upon symfony/console
, and the code to search for a command is located in Symfony\Component\Console\Application::find
, which can be found at https://github.com/symfony/console/blob/master/Application.php#L596. Basically, all registered commands are checked until the shortest, clearly identifiable length - so the approach with similar_text
is already too sophisticated ;)
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?