VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/10-command-line-interface

⇱ Command-Line Interface | MahoCommerce/maho | DeepWiki


Loading...
Last indexed: 15 May 2026 (ea8ab8)
Menu

Command-Line Interface

The Command-Line Interface (CLI) system provides administrative and maintenance functionality through the maho binary. Built on Symfony Console, it offers commands for cache management, indexing, user administration, database operations, and system maintenance. Commands can execute with or without bootstrapping the full Mage framework, depending on operational requirements.

For database schema migrations and setup, see Installation Command. For web-based administration, see Admin Interface. For cron job scheduling via CLI, see Cron System.

CLI Architecture

The maho script serves as the CLI entry point, loading the Symfony Console Application and registering all available commands. The bootstrap process establishes directory constants, loads Composer autoload, and discovers commands from multiple sources. All Maho-specific commands typically extend BaseMahoCommand which provides helper methods like initMaho() to initialize the application state by registering the secure area and initializing the admin app lib/MahoCLI/Commands/BaseMahoCommand.php20-24

CLI Execution Flow

The following diagram illustrates the transition from the maho entry point to the command execution logic.


Sources: maho1-107 lib/MahoCLI/Commands/BaseMahoCommand.php18-35 lib/MahoCLI/CommandDiscoverer.php17-79

For details, see CLI Architecture.

Installation Command

The maho install command provides a non-interactive way to set up the Maho platform. It handles database creation, administrative user setup, and initial configuration lib/MahoCLI/Commands/Install.php30-75 It supports multiple database engines including mysql, pgsql, and sqlite via the --db_engine option lib/MahoCLI/Commands/Install.php49 Additionally, it can download and import sample data, using SampleDataImporter to remap EAV attribute IDs to match the fresh installation lib/MahoCLI/Helper/SampleDataImporter.php25-227

OperationCommandFile
Full Installationmaho installmaho70
Database Migrationmaho migratemaho71

For details, see Installation Command.

Cache Management Commands

Cache commands control Maho's multi-level caching system. These commands allow for flushing specific types or the entire cache storage to ensure configuration or data changes are reflected immediately.

CommandPurposeImplementation
cache:flushFlush all cache typesRegistered in maho36
cache:enableEnable all cache typesRegistered in maho34
cache:disableDisable all cache typesRegistered in maho35
cache:minify:flushFlush minified assetsRegistered in maho37

For details, see Cache Management Commands.

Index Management Commands

Index commands manage Maho's indexing system, which maintains denormalized data structures for storefront performance. These commands interact with the indexer process models.

CommandPurposeImplementation
index:listList indexes and statusRegistered in maho53
index:reindexReindex specific code$index->reindexEverything() lib/MahoCLI/Commands/IndexReindex.php48
index:reindex:allReindex allRegistered in maho55

For details, see Index Management Commands.

User Management Commands

Maho provides CLI utilities for managing both administrative backend users and storefront customers, utilizing their respective models for data persistence.

User Entity Mapping

The diagram below maps CLI commands to their corresponding framework models.


Sources: maho28-43 lib/MahoCLI/Commands/AdminUserChangepassword.php53-61

For details, see User Management Commands.

Database Commands

Direct database interaction is supported through specialized commands that use Maho's resource connections.

CommandPurposeFile
db:connectOpen interactive DB shellmaho44
db:queryExecute raw SQL querymaho45

These commands utilize the underlying database adapters to interact with the configured storage engine.

For details, see Database Commands.

Maintenance and Development Commands

This category includes essential tools for site maintenance, cron execution, and developer productivity.

Cron Execution

The cron:run command allows manual execution of scheduled tasks by group (default/always) or specific job code lib/MahoCLI/Commands/CronRun.php25-28 It supports locking to prevent concurrent execution of the same job lib/MahoCLI/Commands/CronRun.php95-98

CommandPurposeImplementation
cron:listList jobs from XMLMage::helper('cron')->getConfiguredJobs() lib/MahoCLI/Commands/CronList.php36
cron:historyShow execution logRegistered in maho58

Legacy Migration Tools

Maho includes commands to migrate legacy XML-based configurations to modern PHP attributes:

  • legacy:migrate-observers: Migrates <events> observer declarations to #[Maho\Config\Observer] attributes.
  • legacy:migrate-cron: Migrates cron job declarations maho74
  • legacy:migrate-routes: Migrates front controller route declarations maho75

Developer Utilities

  • health-check: Scans the project for legacy core files, deprecated folders, and orphaned resource IDs.
  • serve: Runs the built-in PHP web server maho77
  • shell: Opens an interactive PHP shell (REPL) with Maho initialized maho78
  • config:set/get/delete: Direct manipulation of core configuration data maho86-88
  • log:status: Provides row counts and data sizes for logging tables such as log/visitor and log/customer lib/MahoCLI/Commands/LogStatus.php26-54
  • sys:encryption-key-regenerate: Handles the rotation of system encryption keys maho82
  • dev:module:list: Lists all installed modules maho95
  • dev:lsp:start / dev:mcp:start: Starts Maho Intelligence servers for IDE and AI integration.

For details, see Maintenance and Development Commands.

Sources: maho1-107 lib/MahoCLI/Commands/LogStatus.php23-86 lib/MahoCLI/Commands/CronList.php26-49 lib/MahoCLI/Commands/CronRun.php25-134