LinuxCommandLibrary

magento

Manage and configure Magento applications

TLDR

Enable one or more modules

$ magento module:enable [module1 module2 ...]
copy

Disable one or more modules
$ magento module:disable [module1 module2 ...]
copy

Update the database after enabling modules
$ magento setup:upgrade
copy

Update code and dependency injection configuration
$ magento setup:di:compile
copy

Deploy static assets
$ magento setup:static-content:deploy
copy

Enable maintenance mode
$ magento maintenance:enable
copy

Disable maintenance mode
$ magento maintenance:disable
copy

List all available commands
$ magento list
copy

SYNOPSIS

magento [global-options] [command] [command-options] [arguments]

PARAMETERS

--help, -h
    Displays help for the given command or lists all available commands.

--quiet, -q
    Suppresses all command output, useful for scripting.

--verbose, -v|-vv|-vvv
    Increases the verbosity of messages: -v for normal output, -vv for more verbose debug output, and -vvv for full debug output.

--version, -V
    Displays the Magento application version.

--no-interaction, -n
    Prevents the command from asking interactive questions during execution.

--ansi
    Forces ANSI output, enabling colored and formatted text.

--no-ansi
    Disables ANSI output, useful for environments that don't support it.

--env, -e
    Specifies the application environment for the command (e.g., developer, production).

DESCRIPTION

The magento command, typically invoked as bin/magento from the Magento root directory, is the primary command-line interface (CLI) tool for managing and developing Magento 2 e-commerce applications. It provides a robust set of functionalities for performing essential tasks that range from initial installation and configuration to routine maintenance and advanced development operations. Users can leverage this CLI for actions such as installing Magento, upgrading the platform, managing caches, reindexing data, enabling or disabling modules, configuring cron jobs, generating static files, and performing various database and user management operations. The magento CLI integrates deeply with Magento's architecture, allowing direct interaction with core components like dependency injection (DI) compilation and theme management. It streamlines many tasks that would otherwise require manual configuration or navigating the administrative panel, making it an indispensable tool for Magento developers and administrators.

CAVEATS

The magento command requires a correctly installed Magento instance and a compatible PHP environment. It must typically be executed from the root directory of the Magento installation using bin/magento. Many commands, especially setup and compilation tasks, can be resource-intensive, requiring significant server memory and CPU. Proper file system permissions are critical; ensure the user executing the command has read/write access to Magento files and directories.

FINDING COMMANDS

To list all available top-level commands and their categories, run bin/magento list or bin/magento --help. To get detailed help for a specific command, use bin/magento help <command> (e.g., bin/magento help cache:flush).

EXECUTION CONTEXT

While referred to as the 'magento' command, it is almost always executed from the root directory of a Magento installation using the executable script located at bin/magento. This ensures that the command has access to the correct Magento application context and configuration. It is crucial to ensure correct file system permissions for the user executing the command, especially for write operations like upgrades or cache cleaning.

HISTORY

Prior to Magento 2 (released in 2015), Magento 1 did not have a standardized, official command-line tool for core operations; third-party tools like n98-magerun filled this gap. Magento 2 introduced the official bin/magento CLI tool, built upon the Symfony Console component. This marked a significant improvement in developer experience and enabled greater automation of Magento administration and development tasks. The tool has continued to evolve with subsequent Magento versions (e.g., 2.3, 2.4), adding new commands and refining existing functionalities to support the platform's growing capabilities.

SEE ALSO

php(1), composer(1), mysql(1), nginx(8), apache2(8)

Copied to clipboard