Magento 2 Useful Commands

While working on Magento, if you are in dilemma regarding the commands of Magento 2, here are few useful commands that will really help you to work on Magento flawlessly.

Let’s have a look at some helpful Magento 2 commands.

Run the following commands under root directory. For using these commands you will need to have SSH access to your server or else you can use the command line for local access.

Setup Upgrade Command :

php bin/magento setup:upgrade

When to use:

When you do some changes in Magento installation setup like change in default module files or create your own extension you need to use setup upgrade command.

Options:

[ --keep-generated ]When you don’t want to remove magento generated file ,this command is used to keep that files.

Example:

php bin/magento setup:upgrade --keep-generated

Cache Flush Command:

php bin/magento cache:flush

When to use:

Cache are generated automatically. In some configuration cache flush automatically and in some changes you have to flush cache from admin panel or using above command to remove default cache generated by Magento.

Cache Clear Command:

php bin/magento cache:clear

When to use:

It seems like cache:flush command but difference is flush remove default cache and clear remove all items of cache.

Indexer Reindex Command:

php bin/magento indexer:reindex

When to use:

After creating attribute set / newsletter / sitemap / confirm & transaction order / catalog price rule there is warning come like One or more Indexers are invalid that time use this command.

Deploy Mode Show Command:

php bin/magento deploy:mode:show

When to use:

Magento provide 3 types of mode: Production , Developer , Default . Each mode have its own purpose so you have to check in which mode you are working for developing.

Set Developer Mode Command:

php bin/magento deploy:mode:set developer

When to use:

In developer mode some static files create automatic or it take from it’s parent so it is helpful while you are developing customization or extensions.

Set Production Mode Command:

php bin/magento deploy:mode:set production

When to use:

In production mode static files are not generated automatically. So SEO purpose this command is used.

Static Content Deploy Command:

php bin/magento setup:static-content:deploy

When to use:

When you do some changes in magento static files like css,js files you have to deploy it using this command.

if you want to deploy specific theme or language then you can use below

About us

SimBeez IT Solutions LLP provides innovative IT solutions. SimBeez – an IT company that has been serving its clients with satisfactory IT services. We specialize in Web development, Mobile Apps development, Game development, Odoo/OpenERP development, Magento (E-commerce development), Graphics designing, SEO and Digital Marketing.