With the new version of Magento 2, there is a newer CLI tool available as well which is more powerful than the previous Mage tool. I’ll be sharing how you can use Magento 2 CLI with the most common options that we will be using while managing your store.
As the name suggest, this option can manipulate the Magento’s Caching option. You can enable, disable, clean, flush or check status of magento’s caching with this option. Few examples are:
magento cache:status magento cache:disable config magento cache:disable full_page magento cache:flush
The indexer will be a more widely used option in Magento 2 as now there is no method to update indexing manually from Magento’s Admin. Besides reindexing, you have the options to set indexing mode and to check the status of indexer via CLI.
magento indexer:info magento indexer:set‐mode schedule customer_grid magento indexer:reindex customer_grid magento indexer:reindex
With this option, you can create admin user from command line or you can unlock the users that are already created.
magento admin:user:create ‐‐admin‐user="example" ‐‐admin‐password="example123" ‐‐admin‐email="firstname.lastname@example.org" ‐‐admin‐firstname="example" ‐‐admin‐lastname="example"
This option can be used to enable, disable, uninstall or check status of all the installed modules of Magento. Disabling or uninstalling of module will fail with this option if there is any dependency of that module. Few examples are:
magento module:status magento module:disable example magento module:uninstall example
With this option, we can execute the scheduled Magento’s Cron jobs manually. You can put this command in the scheduler, so the application’s task can be executed in a timely manner.
There are plenty of things you can do with this option, but we’ll go through two of them as I think these are ones which you will be using more frequently.
We can backup our application’s code, database, and media files through this option. Backup can be found in var/backup/directory of your web root.
magento setup:backup ‐‐code ‐‐media ‐‐db
This option can be used to make configuration changes on Magento. The changes involve DB parameters, admin URL, etc. You can see your provided values reflected in app/etc/env.php file.
magento setup:config:set ‐‐backend‐frontname="admin" ‐‐db‐host="localhost" ‐‐db‐name="example" ‐‐db‐user="example" ‐‐db‐password="example"
Fairly speaking, we have more freedom in working via command line on this new version of Magento. With this flexibility, there is little need for using Magento admin for store management.
We know that we do not have Magento 2 as an app on Cloudways. Well, we are creating a dedicated stack for Magento 2 websites. Till then, you can install Magento 2 on PHP using this tutorial. We recommend you to use our plain PHP stack.