3

Can anyone please explain how the all magento command work in magento2(I want to understand backend process)

Like:

IF I am running command php bin/magento module:status which file will affect and how it display?

I want to know about all the commands which we mostly use by command line.

3

ObjectManagerProvider.php is the starting point of initializing all commands with application run

setup/src/Magento/Setup/Model/ObjectManagerProvider.php

Here createCliCommands() function creates cli commands and initialize them with application instance

createCliCommands() function gets list of command instances from getCommands() function which returns all command classes

You can check all command classes from getCommandsClasses()

setup/src/Magento/Setup/Console/CommandList.php

Here is the list of all command classes

\Magento\Setup\Console\Command\AdminUserCreateCommand::class,
\Magento\Setup\Console\Command\BackupCommand::class,
\Magento\Setup\Console\Command\ConfigSetCommand::class,
\Magento\Setup\Console\Command\CronRunCommand::class,
\Magento\Setup\Console\Command\DbDataUpgradeCommand::class,
\Magento\Setup\Console\Command\DbSchemaUpgradeCommand::class,
\Magento\Setup\Console\Command\DbStatusCommand::class,
\Magento\Setup\Console\Command\DependenciesShowFrameworkCommand::class,
\Magento\Setup\Console\Command\DependenciesShowModulesCircularCommand::class,
\Magento\Setup\Console\Command\DependenciesShowModulesCommand::class,
\Magento\Setup\Console\Command\DiCompileCommand::class,
\Magento\Setup\Console\Command\GenerateFixturesCommand::class,
\Magento\Setup\Console\Command\I18nCollectPhrasesCommand::class,
\Magento\Setup\Console\Command\I18nPackCommand::class,
\Magento\Setup\Console\Command\InfoAdminUriCommand::class,
\Magento\Setup\Console\Command\InfoBackupsListCommand::class,
\Magento\Setup\Console\Command\InfoCurrencyListCommand::class,
\Magento\Setup\Console\Command\InfoLanguageListCommand::class,
\Magento\Setup\Console\Command\InfoTimezoneListCommand::class,
\Magento\Setup\Console\Command\InstallCommand::class,
\Magento\Setup\Console\Command\InstallStoreConfigurationCommand::class,
\Magento\Setup\Console\Command\ModuleEnableCommand::class,
\Magento\Setup\Console\Command\ModuleDisableCommand::class,
\Magento\Setup\Console\Command\ModuleStatusCommand::class,
\Magento\Setup\Console\Command\ModuleUninstallCommand::class,
\Magento\Setup\Console\Command\MaintenanceAllowIpsCommand::class,
\Magento\Setup\Console\Command\MaintenanceDisableCommand::class,
\Magento\Setup\Console\Command\MaintenanceEnableCommand::class,
\Magento\Setup\Console\Command\MaintenanceStatusCommand::class,
\Magento\Setup\Console\Command\RollbackCommand::class,
\Magento\Setup\Console\Command\UpgradeCommand::class,
\Magento\Setup\Console\Command\UninstallCommand::class,
\Magento\Setup\Console\Command\DeployStaticContentCommand::class

Command module:status has been declare ModuleStatusCommand.php

setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php

protected function execute(InputInterface $input, OutputInterface $output)
{
    $moduleList = $this->objectManagerProvider->get()->create(\Magento\Framework\Module\ModuleList::class);
    $output->writeln('<info>List of enabled modules:</info>');
    $enabledModules = $moduleList->getNames();
    if (count($enabledModules) === 0) {
        $output->writeln('None');
    } else {
        $output->writeln(join("\n", $enabledModules));
    }
    $output->writeln('');

    $fullModuleList = $this->objectManagerProvider->get()->create(\Magento\Framework\Module\FullModuleList::class);
    $output->writeln("<info>List of disabled modules:</info>");
    $disabledModules = array_diff($fullModuleList->getNames(), $enabledModules);
    if (count($disabledModules) === 0) {
        $output->writeln('None');
    } else {
        $output->writeln(join("\n", $disabledModules));
    }
}
1

The command 'module:status' has been declared in

setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php

Use a grep command to find out in which module the Console Command is declared:

grep -r 'module:status' vendor/magento/

and then in this case it is in magento2-base setup which will be placed in the setup folder during installation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.