VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/10.2-installation-command

⇱ Installation Command | MahoCommerce/maho | DeepWiki


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

Installation Command

The install command provides a CLI-based installation process for Maho, enabling scripting and automation beyond the web-based installation wizard. This command manages database creation, admin user setup, optional sample data import with EAV attribute remapping, and localization configuration through a rich set of command options.

This page details the command's implementation, options, data handling procedures, localization setup, and multi-database support.

For general CLI architecture and command discovery, see CLI Architecture (10.1). For subsequent administration, use the cache and index management commands Cache Management Commands (10.3), Index Management Commands (10.4).


Command Registration and Entry Point

The install command is implemented as the class MahoCLI\Commands\Install following Symfony Console conventions. It is registered using the #[AsCommand] attribute with the command name install and inherits from BaseMahoCommand which provides Maho-specific console scaffolding.

The command delegates the core installation logic to the singleton Mage_Install_Model_Installer_Console, which orchestrates schema creation, configuration writing, and admin user creation.

Implementation Highlights:

Natural Language to Code Entity Mapping: CLI Entry Point


Sources: lib/MahoCLI/Commands/Install.php26-31 lib/MahoCLI/Commands/Install.php104-105 lib/MahoCLI/Commands/Install.php78-122


Command Options

The install command accepts multiple options to customize the store's environment, database, admin user, session handling, and additional behaviors such as sample data and forced reinstall.

These options are grouped logically here.

License and Localization Options

OptionTypeDescriptionDefault
--license_agreement_acceptedrequired stringMust be "yes" to proceed with installation-
--localerequired stringLocale code, e.g. en_US, fr_FR-
--timezonerequired stringIANA timezone name, e.g. America/New_York-
--default_currencyrequired stringCurrency code, e.g. USD, EUR-

Database Connection Options

OptionTypeDescriptionDefault
--db_hostrequiredDatabase host or socket (e.g. localhost:3307, /var/run/mysqld/mysqld.sock)-
--db_namerequiredDatabase name for MySQL/PostgreSQL, or file path for SQLite-
--db_userrequiredDatabase user-
--db_passrequiredDatabase password-
--db_prefixoptionalTable prefix for all tables""
--db_engineoptionalDatabase engine; one of mysql, pgsql, sqlitemysql

Web Access and Admin Panel Options

OptionTypeDescriptionDefault
--admin_frontnameoptionalAdmin URL path, e.g. /adminadmin
--urlrequiredStore frontend URL, ensure trailing slash /-
--use_secureoptionalEnable HTTPS for frontend URLs (true/false)false
--secure_base_urloptionalSecure base URL, e.g. https://example.com/store/-
--use_secure_adminoptionalEnable HTTPS for admin panel (true/false)false

Admin User Identity and Credentials

OptionTypeDescription
--admin_firstnamerequiredAdmin user first name
--admin_lastnamerequiredAdmin user last name
--admin_emailrequiredAdmin user email address
--admin_usernamerequiredAdmin user login name
--admin_passwordrequiredAdmin user password

Additional Options

OptionTypeDescriptionDefault
--session_saveoptionalSession storage type, one of files or dbfiles
--sample_dataoptionalInstall sample data along with main installation-
--forceflagForce reinstall, drops DB and deletes local.xml-

Sources: lib/MahoCLI/Commands/Install.php33-75


Installation Flow and Data Handling

The installation career is initiated in the execute() method of MahoCLI\Commands\Install. Here is the detailed flow:

  1. Check for --force option: if present, attempt destructive cleanup including DB drop and config file removal lib/MahoCLI/Commands/Install.php81-85

  2. If --sample_data and --db_prefix both set, re-invoke the command without the prefix due to hardcoded table names in sample data SQL lib/MahoCLI/Commands/Install.php87-97

  3. Initialize Maho environment context (initMaho()) lib/MahoCLI/Commands/Install.php99

  4. Instantiate the install/installer_console singleton lib/MahoCLI/Commands/Install.php104-105

  5. Call init($app), setArgs(), and install() on the installer singleton to perform schema creation, core data seeding, and admin user creation lib/MahoCLI/Commands/Install.php107-121

  6. Report errors or success messages lib/MahoCLI/Commands/Install.php112-122

  7. Invoke localization suggestions for further user actions lib/MahoCLI/Commands/Install.php124

  8. If sample data is requested, download and extract the appropriate version of sample data corresponding to the Maho version branch lib/MahoCLI/Commands/Install.php129-160 The temporary download is handled via file_get_contents() into a temp file followed by extraction using tar. Errors during this process are reported.

Sequence Overview


Sources: lib/MahoCLI/Commands/Install.php78-124 lib/MahoCLI/Commands/Install.php129-160


Multi-Database Engine Support

Maho install command supports multiple database backends, adapting connection details and behavior accordingly.

Supported Engines

DSN and PDO Setup

The install command interprets options such as db_host, db_name, db_user, db_pass, and db_engine to form the DSN string used by PDO or Doctrine DBAL to connect to the database.

Force Reinstallation Notes

The forced reinstall option drops all tables in the configured database to ensure a clean environment. This is done safely using platform-specific SQL commands, and the installer deletes the local.xml configuration file to trigger a fresh configuration cycle on next bootstrap.

Sources: lib/MahoCLI/Commands/Install.php48-50 lib/MahoCLI/Commands/Install.php339-442 lib/MahoCLI/Commands/Install.php456-494 lib/MahoCLI/Commands/Install.php556


Sample Data Installation with EAV Attribute ID Remapping

Maho's sample data installation is a delicate process that requires remapping attribute and option IDs from the sample data SQL dump to align with the freshly installed database IDs.

Why ID Remapping?

The sample data SQL contains hardcoded attribute ids which will not match the IDs generated during fresh installation due to auto-increment behavior. To ensure EAV attribute references are consistent, IDs must be remapped.

SampleDataImporter Role

The class MahoCLI\Helper\SampleDataImporter is responsible for importing raw sample SQL with remapping logic.

It:

  • Parses sample SQL to detect old attribute IDs and option IDs.
  • Queries the current database to retrieve new attribute IDs using entity type code and attribute code keys.
  • Performs attribute and option ID remapping in all relevant EAV tables.
  • Updates mapping tables such as eav_attribute_option and catalog_eav_attribute.
  • Allows correct import of EAV sample data with relational consistency.

Supported Remapping Tables

Key tables for ID remapping are listed as constants in the class, such as:

  • Tables with attribute_id columns to remap, e.g., catalog_product_entity_int, customer_eav_attribute, eav_attribute_option, etc.
  • Tables with option_id columns to remap, e.g., eav_attribute_option_swatch.

Directory and Functionality Overview


Process Summary

  • On construction, SampleDataImporter loads entity type IDs and table schemas to confirm columns and tables involved lib/MahoCLI/Helper/SampleDataImporter.php129-175
  • On import, sample SQL is parsed for existing attribute groups, attributes, and options.
  • Current attribute IDs are fetched from the live database to generate a mapping.
  • The sample data SQL is adjusted, substituting old attribute IDs with the current ones before execution.
  • This remapping guarantees that EAV references remain integral, preventing data corruption.

Sources: lib/MahoCLI/Helper/SampleDataImporter.php25-127 lib/MahoCLI/Commands/Install.php129-160


Localization and Post-Installation Suggestions

After a successful install, the command outputs recommendations for additional localization setup steps.

Localization Settings

These localization settings are accepted as CLI options:

  • Locale
  • Timezone
  • Default Currency

If a non-US locale is selected, the installer suggests:

  • Importing regional data (e.g., regions/state info) via ./maho sys:directory:regions:import command.
  • Installing official language packs from Composer repository, e.g., mahocommerce/maho-language-de_de.

Auxiliary Commands for Reference Data

To assist with valid input for localization options, Maho provides CLI commands listing valid values:

CommandDescription
sys:localesLists all valid locale codes
sys:currenciesLists available currencies
sys:timezonesLists valid timezone identifiers

These commands output tables of codes and descriptions to standard output for easy reference.

Example: Locale Listing Command

Sources: lib/MahoCLI/Commands/Install.php302-337 lib/MahoCLI/Commands/SysLocales.php23-46 lib/MahoCLI/Commands/SysCurrencies.php23-46 lib/MahoCLI/Commands/SysTimezones.php23-46


Force Installation Option

The --force option enables a destructive reinstallation that:

  1. Deletes the configuration file app/etc/local.xml to reset configuration cache and trigger a full re-setup on next application bootstrap.
  2. Drops all database tables to clear previous data and schema, including tables with foreign key constraints handled appropriately per database engine.

This clearing ensures no legacy schema or data remains that might conflict with a fresh install.

Implementation Notes:

Force Install Workflow Snippet


Sources: lib/MahoCLI/Commands/Install.php81-85 lib/MahoCLI/Commands/Install.php339-442


Summary

The maho install command is a comprehensive CLI installer designed for scripting and automation. It handles:

  • Configuring the database connection and engine
  • Creating core database schema and admin user
  • Optionally installing sample data with EAV attribute remapping
  • Setting localization options for locale, currency, and timezone
  • Safe forced reinstall with full DB reset and config cleanup

Helper commands aid users in selecting valid locale, currency, and timezone values, enhancing automation robustness.

This command is central to automated Maho deployments, enabling repeatable and configurable store initialization from the command line.


Sources:

Refresh this wiki

On this page