![]() |
VOOZH | about |
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).
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:
#[AsCommand(name: 'install')] in MahoCLI\Commands\Install lib/MahoCLI/Commands/Install.php26-31Mage::getSingleton('install/installer_console') to access the installer lib/MahoCLI/Commands/Install.php104-105execute() method, handling errors, and outputting status messages lib/MahoCLI/Commands/Install.php78-122Sources: lib/MahoCLI/Commands/Install.php26-31 lib/MahoCLI/Commands/Install.php104-105 lib/MahoCLI/Commands/Install.php78-122
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.
| Option | Type | Description | Default |
|---|---|---|---|
--license_agreement_accepted | required string | Must be "yes" to proceed with installation | - |
--locale | required string | Locale code, e.g. en_US, fr_FR | - |
--timezone | required string | IANA timezone name, e.g. America/New_York | - |
--default_currency | required string | Currency code, e.g. USD, EUR | - |
| Option | Type | Description | Default |
|---|---|---|---|
--db_host | required | Database host or socket (e.g. localhost:3307, /var/run/mysqld/mysqld.sock) | - |
--db_name | required | Database name for MySQL/PostgreSQL, or file path for SQLite | - |
--db_user | required | Database user | - |
--db_pass | required | Database password | - |
--db_prefix | optional | Table prefix for all tables | "" |
--db_engine | optional | Database engine; one of mysql, pgsql, sqlite | mysql |
| Option | Type | Description | Default |
|---|---|---|---|
--admin_frontname | optional | Admin URL path, e.g. /admin | admin |
--url | required | Store frontend URL, ensure trailing slash / | - |
--use_secure | optional | Enable HTTPS for frontend URLs (true/false) | false |
--secure_base_url | optional | Secure base URL, e.g. https://example.com/store/ | - |
--use_secure_admin | optional | Enable HTTPS for admin panel (true/false) | false |
| Option | Type | Description |
|---|---|---|
--admin_firstname | required | Admin user first name |
--admin_lastname | required | Admin user last name |
--admin_email | required | Admin user email address |
--admin_username | required | Admin user login name |
--admin_password | required | Admin user password |
| Option | Type | Description | Default |
|---|---|---|---|
--session_save | optional | Session storage type, one of files or db | files |
--sample_data | optional | Install sample data along with main installation | - |
--force | flag | Force reinstall, drops DB and deletes local.xml | - |
Sources: lib/MahoCLI/Commands/Install.php33-75
The installation career is initiated in the execute() method of MahoCLI\Commands\Install. Here is the detailed flow:
Check for --force option: if present, attempt destructive cleanup including DB drop and config file removal lib/MahoCLI/Commands/Install.php81-85
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
Initialize Maho environment context (initMaho()) lib/MahoCLI/Commands/Install.php99
Instantiate the install/installer_console singleton lib/MahoCLI/Commands/Install.php104-105
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
Report errors or success messages lib/MahoCLI/Commands/Install.php112-122
Invoke localization suggestions for further user actions lib/MahoCLI/Commands/Install.php124
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.
Sources: lib/MahoCLI/Commands/Install.php78-124 lib/MahoCLI/Commands/Install.php129-160
Maho install command supports multiple database backends, adapting connection details and behavior accordingly.
MySQL (default):
Uses standard MySQL DSN format. Force reinstall disables foreign key checks during table drops using SET FOREIGN_KEY_CHECKS = 0 to allow dropping tables with constraints.
lib/MahoCLI/Commands/Install.php48-50 lib/MahoCLI/Commands/Install.php418
PostgreSQL:
Requires the use of CASCADE when dropping tables to ensure dependent objects are also removed. After import, sequences are updated with updatePostgresSequences().
lib/MahoCLI/Commands/Install.php433 lib/MahoCLI/Commands/Install.php456-494
SQLite:
Supports relative file paths from var/db/, absolute paths, or using :memory: for in-memory DB.
lib/MahoCLI/Commands/Install.php556
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.
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
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.
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 RoleThe class MahoCLI\Helper\SampleDataImporter is responsible for importing raw sample SQL with remapping logic.
It:
eav_attribute_option and catalog_eav_attribute.Key tables for ID remapping are listed as constants in the class, such as:
attribute_id columns to remap, e.g., catalog_product_entity_int, customer_eav_attribute, eav_attribute_option, etc.option_id columns to remap, e.g., eav_attribute_option_swatch.SampleDataImporter loads entity type IDs and table schemas to confirm columns and tables involved lib/MahoCLI/Helper/SampleDataImporter.php129-175Sources: lib/MahoCLI/Helper/SampleDataImporter.php25-127 lib/MahoCLI/Commands/Install.php129-160
After a successful install, the command outputs recommendations for additional localization setup steps.
These localization settings are accepted as CLI options:
If a non-US locale is selected, the installer suggests:
./maho sys:directory:regions:import command.mahocommerce/maho-language-de_de.To assist with valid input for localization options, Maho provides CLI commands listing valid values:
| Command | Description |
|---|---|
sys:locales | Lists all valid locale codes |
sys:currencies | Lists available currencies |
sys:timezones | Lists valid timezone identifiers |
These commands output tables of codes and descriptions to standard output for easy reference.
Implemented in MahoCLI\Commands\SysLocales, it initializes Maho and retrieves locales via Mage::app()->getLocale()->getOptionLocales() lib/MahoCLI/Commands/SysLocales.php23-46
Similar commands exist for currencies and timezones lib/MahoCLI/Commands/SysCurrencies.php23-46 lib/MahoCLI/Commands/SysTimezones.php23-46
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
The --force option enables a destructive reinstallation that:
app/etc/local.xml to reset configuration cache and trigger a full re-setup on next application bootstrap.This clearing ensures no legacy schema or data remains that might conflict with a fresh install.
CASCADE in Postgres as necessary lib/MahoCLI/Commands/Install.php403-442Sources: lib/MahoCLI/Commands/Install.php81-85 lib/MahoCLI/Commands/Install.php339-442
The maho install command is a comprehensive CLI installer designed for scripting and automation. It handles:
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