As you know, Magento 2 has the console command line and it is very useful. You can quickly reindex or flush the cache at fast speed. In this tutorial, I will show you how to use Magento 2 Command line Interface properly.
How to use Magento 2 Command line Interface
To use Magento 2 Command line Interface, you need to follow:
- Step 1: Install Php_cli
- Step 2: Some most common command line in Magento 2
- Step 3: Use command line that you want
Step 1: Install Php_cli
To use the Magento 2 console, you must install the php_cli. Please go to the Magento 2 root folder and type:
If the list of command is show, the php_cli is installed so you can use the Magento 2 console normally. If it is not show, you should install the php_cli.
If your sever is ubuntu, you can install by the command:
Sudo apt-get install php-cli
Step 2: Some most used command line in Magento 2 Command Line Interface (CLI):
- Install module and upgrade module: php bin/magento setup:upgrade
- Switch to the developer mode or production mode: php bin/magento deploy:mode:set developer (or production)
- Show current mode: php bin/magento deploy:mode:show
- Deploy static content: php bin/magento setup:static-content:deploy
- Di compile: php bin/magento setup:di:compile
- Reindex: php bin/magento indexer:reindex
- Flush magento cache: php bin/magento cache:flush
Step 3: Use command line that you want
You can also use php bin/magento to show all the command line.
Thank you! This is how to use Magento 2 Command line Interface tutorial!
[bctt tweet=”Quickly Reindex or Flush cache at incredible speed – Get the most out of Magento 2 Command Line Interface (CLI)” username=”Magestore”]