Search This Blog

Thursday, November 10, 2016

Magento 2 CLI/Terminal Commands

Commands for Magento 2x

If you are a Terminal/CLI ninja and have been seeking for nifty CLI commands, head forward!

Note: You may/may not have to enter 'sudo', depending on your folder permission settings. In my case I had to so I have added 'sudo' before each of my command.

>> To view Magento Help Commands:
php bin/magento

>> To REINDEX CACHE: php bin/magento indexer:reindex

>> To Clean Cache:
php bin/magento cache:clean

- Cache Options: config , layout , block_html , collections , reflection , db_ddl , eav , customer_notification , full_page , config_integration , config_integration_api , translate , config_webservice

- Cache Options Usage:
  • php bin/magento cache:clean config layout translate
  • php bin/magento cache:flush – flush cache storage
  • php bin/magento cache:enable
  • php bin/magento cache:disable
  • php bin/magneto cache:status – check cache status

>> Maintenance Mode:

  • Sets maintenance mode exempt IPs: php bin/magento maintenance:allow-ips your_ip_address1 ip_address2
  • Disable Allowed IPs: php bin/magento maintenance:enable --ip=none
  • Disables maintenance mode: php bin/magento maintenance:disable 
  • Enable maintenance mode: php bin/magento maintenance:enable 
  • Displays maintenance mode status: php bin/magento maintenance:status
For more on Maintenance Mode, you may check Magento Guide at:

    >> Info:
    • Displays the Magento Admin URI: php bin/magento info:adminuri 
    • Displays the list of available currencies: php bin/magento info:currency:list 
    • Displays the list of available language locales: php bin/magento info:language:list 
    • Displays the list of available timezones: php bin/magento info:timezone:list

    >> Admin Solutions: 

      >> Module:
      • Disables specified modules: php bin/magento module:disable module_name --clear-static-content
      • Enables specified modules: php bin/magento module:enable module_name --clear-static-content
      • Displays status of modules: php bin/magento module:status 
      • Uninstalls modules installed by composer: sudo php bin/magento module:uninstall

      >> Setup:
      • Takes BACKUP of Magento Application code base, media and database: php bin/magento setup:backup
      • Run CRON for Setup Application: php bin/magento setup:cron:run
      • Installs and upgrades data in the DB: php bin/magento setup:db-data:upgrade
      • Installs and upgrades the DB schema: php bin/magento setup:db-schema:upgrade
      • Checks if DB schema or data requires upgrade: php bin/magento setup:db:status
      • Generates DI configuration and all missing classes that can be auto-generated: php bin/magento setup:di:compile
      • Installs the Magento application: php bin/magento setup:install
      • Rolls back Magento Application codebase, media and database: php bin/magento setup:rollback
      • Deploys static view files: php bin/magento  setup:static-content:deploy
      • Installs the store configuration: php bin/magento setup:store-config:set
      • Uninstalls the Magento application: php bin/magento setup:uninstall
      • Upgrades the Magento application, DB data, and schema: php bin/magento setup:upgrade

      >> Theme:
      Uninstall Theme: php bin/magento theme:uninstall theme_name

      Probably the above method is only applicable to themes that have been installed using composer. For other themes that haven't been installed using composer, please refer to the methods below:
      An important point I noticed from Reference 2 was this SQL query:

      There is a table in database named as theme.You can use the below code to delete your theme:

       USE dbname;  
       DELETE FROM theme where theme_id=5;  

      >> Sample Data:
      • Deploy sample data modules: php bin/magento sampledata:deploy
      • Remove all sample data packages from composer.json: php bin/magento sampledata:remove
      • Reset all sample data modules for re-installation: php bin/magento sampledata:reset

      >> Magento Mode:
      • Display current mode: php bin/magento deploy:mode:show
      • Change mode: magento deploy:mode:set {mode} [-s|--skip-compilation]
        is required; it can be either developer or production
        --skip-compilation is an optional parameter you can use to skip code compilation when you change to production mode.
      • Change to production mode: magento deploy:mode:set production
      • Change to developer mode: If you’re changing from production mode to developer mode, delete the contents of the var/generation and var/di directories:

         rm -rf <your Magento install dir>/var/di/* <your Magento install dir>/var/generation/*   
         php bin/magento deploy:mode:set developer 
         php bin/magento module:enable [--force] Magento_Developer  

        No comments:

        Post a Comment

        Thank you for your Feedback!

        Top Magento Hosting:

        Top 5 Posts (Weekly)