CLI tool
Every Maho based project comes with a tool to run various tasks from the command line, find it in the root of your project:
$ ./maho
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
--silent Do not output any message
-q, --quiet Only errors are displayed. All other output is suppressed
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
completion Dump the shell completion script
create-command Create a new command that will integrate into your project's Maho CLI set of commands
health-check Health check your Maho project
help Display help for a command
install Install Maho
list List commands
migrate Apply pending database schema and data updates from modules
serve Run Maho with the built in web server
shell Opens an interactive PHP shell with Maho bootstrapped
admin
admin:user:change-password Change password of an admin users
admin:user:create Create an admin user
admin:user:disable Enable an admin user
admin:user:enable Enable an admin user
admin:user:list List all admin users
cache
cache:disable Disable all caches
cache:enable Enable all caches
cache:flush Flush cache
cache:minify:flush Flush minified CSS/JS cache
config
config:delete Delete configuration values from core_config_data table
config:get Get specific configuration path values
config:set Set configuration values in core_config_data table
cron
cron:history List cron jobs executions stored in the database
cron:list List cron jobs configured in the XML files
cron:run Run a group of cron processes (default/always) or a single job_code (eg: newsletter_send_all)
customer
customer:change-password Change password of a customers
customer:create Create a customer
customer:delete Delete customers
customer:list List all customers
db
db:connect Opens the database command-line interface using credentials from your local.xml file
db:query Execute a SQL query using the database credentials from your local.xml file
email
email:config:show Show email configuration and settings
email:queue:clear Clear emails from the queue
email:queue:process Manually process the email queue
email:test:queue Send a test email via the queue system
email:test:send Send a test email
feed
feed:generate Generate a specific feed
feed:generate:all Generate all enabled feeds
feed:list List all feeds with status
feed:validate Validate an existing feed file without regenerating
frontend
frontend:layout:debug Debug layout for a given URL showing handles, XML files, and block tree
frontend:theme:create Create a new frontend theme with proper scaffolding
index
index:list List all indexes
index:reindex Reindex a single index
index:reindex:all Reindex all indexes
index:reindex:product Reindex specific product(s) across all or specified indexers
legacy
legacy:rename-mysql4-classes Search for old Mysql4 classes and replaces them with Resource classes
log
log:clean Clean log tables in the database
log:status Show status for log tables in the database
maintenance
maintenance:disable Disable maintenance mode
maintenance:enable Enable maintenance mode
maintenance:status Show maintenance mode status
phpstorm
phpstorm:metadata:generate Generate PhpStorm metadata files for better IDE support
sys
sys:currencies Get all available currencies
sys:directory:regions:import Import states/provinces for a country from ISO 3166-2 standard with localization
sys:encryptionkey:regenerate Generate a new encryption key and save it to local.xml
sys:locales Get all available locales
sys:timezones Get all available timezones
translations
translations:missing Display used translations strings that are missing from csv files
translations:unused Display defined translations strings that are not used in templates
This tool is inspired by Laravel Artisan, n98-magerun, and it was created using the awesome Symfony Console component.
Available commands
The list of the built-in commands is growing rapidly, at the moment yon can either run ./maho within your Maho based project or you can check Maho CLI commands directory within our GitHub repository.
All commands should be self-explanatory, also thanks to the inline descriptions.
Add your custom commands
Using the built-in command generator
The easiest way to create a new command is to run:
The generator will prompt you for:
- Command name (e.g.,
my-custom-commandorcache:clean) - Command description
It will automatically:
- Create the command file in the correct location (
lib/MahoCLI/Commands) - Set up the proper namespace and class name
- Add all necessary imports and boilerplate code
Now you can edit your newly create file in lib/MahoCLI/Commands.
Manual creation
Alternatively, you can create commands manually:
- Create
lib/MahoCLI/Commandsin the main directory of your project - Create your command file, e.g.
MyCustomCommand.phpinlib/MahoCLI/Commandsjust like:<?php namespace MahoCLI\Commands; use Mage; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'my-custom-command', description: 'This command is just a test' )] class MyCustomCommand extends BaseMahoCommand { protected function execute(InputInterface $input, OutputInterface $output): int { $this->iniMaho(); $output->writeln("<info>IT WORKED!</info>"); return Command::SUCCESS; } } - Add a PSR4 autoload configuration in your
composer.json - run
composer dump-autoload
Now you can run ./maho and you will see it appear in the list of available commands:
Available commands:
completion Dump the shell completion script
help Display help for a command
install Install Maho
list List commands
my-custom-command This command is just a test
serve Run Maho with the built in web server
and you will be able to run it with