Skip to content

Instantly share code, notes, and snippets.

@zigojacko
Last active December 16, 2022 14:38
Show Gist options
  • Select an option

  • Save zigojacko/2738b75a69f2ae44ffb706601ed8ffef to your computer and use it in GitHub Desktop.

Select an option

Save zigojacko/2738b75a69f2ae44ffb706601ed8ffef to your computer and use it in GitHub Desktop.
Magento 2 CLI Commands / Cheatsheet

Magento 2 CLI Commands / Cheatsheet

Lists available Magento 2 CLI commands

  • bin/magento

Cache

Check the status of cache types

bin/magento cache:status

Output:

config: 1
layout: 1
block_html: 1
collections: 1
db_ddl: 1
eav: 1
full_page: 1
translate: 1
config_integration: 1
config_integration_api: 1
config_webservice: 1

Clean cache types

bin/magento cache:clean

Output:

$ bin/magento cache:clean                  
Cleaned cache types:                           
config                                         
layout                                         
block_html                                     
collections                                    
reflection                                     
db_ddl                                         
eav                                            
customer_notification                          
full_page                                      
config_integration                             
config_integration_api                         
translate                                      
config_webservice

Reindex

Reindex all

bin/magento indexer:reindex

Example Output:

$ bin/magento indexer:reindex                  
Design Config Grid index has been rebuilt successfully in 00:00:00
Customer Grid index has been rebuilt successfully in 00:00:00
Category Products index has been rebuilt successfully in 00:00:00
Product Categories index has been rebuilt successfully in 00:00:00
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Product EAV index has been rebuilt successfully in 00:00:00
Stock index has been rebuilt successfully in 00:00:00
Inventory index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:00
Google Product Removal Feed index has been rebuilt successfully in 00:00:00
Google Product Feed index has been rebuilt successfully in 00:00:00

Check index status

bin/magento indexer:status

Deploy static content

Main/only store

bin/magento setup:static-content:deploy

Specific stores

bin/magento setup:static-content:deploy en_GB

Extensions

Enable

bin/magento module:enable <VendorName>_<ComponentName> --clear-static-content

Disable

bin/magento module:disable <VendorName>_<ComponentName> --clear-static-content

Status

bin/magento module:status

Example: bin/magento module:status J2t_Payplug

Plesk

/opt/plesk/php/x.x/bin/php -dmemory_limit=-1 -f bin/magento s:up; /opt/plesk/php/x.x/bin/php -dmemory_limit=-1 -f bin/magento s:s:d -f en_US en_GB; /opt/plesk/php/x.x/bin/php -dmemory_limit=-1 -f bin/magento c:c;

Example: /opt/plesk/php/7.2/bin/php -dmemory_limit=-1 -f bin/magento s:up; /opt/plesk/php/7.2/bin/php -dmemory_limit=-1 -f bin/magento s:s:d -f en_US en_GB; /opt/plesk/php/7.2/bin/php -dmemory_limit=-1 -f bin/magento c:c;

Note: You can actually set the PHP version for the current shell session like this:

export PATH=/opt/plesk/php/x.x/bin:$PATH;

Example: export PATH=/opt/plesk/php/7.1/bin:$PATH;

Images

Regenerate and resize all images

php -dmemory_limit=-1 bin/magento catalog:images:resize

Maintenance Mode

Enable for specific IP address

php -dmemory_limit=-1 -f bin/magento maintenance:enable --ip=xx.xx.xx.xx

Full Command to Run

bin/magento maintenance:enable && rm -rf generated/* && php bin/magento setup:upgrade && php -d memory_limit=-1 bin/magento setup:di:compile && rm -rf var/view_preprocessed && rm -rf pub/static/* && php -d memory_limit=-1 bin/magento setup:static-content:deploy && php bin/magento cache:clean && bin/magento maintenance:disable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment