My ‘Fix All’ One Liner Command for Magento 2
- Published 5th Apr 2018
Last edited 5th Apr 2018
We as Developers run into issues with Magento 2 – a lot. Clear cache, reindex, regenerate static files, enable modules etc. etc. the list goes on. So I made it simple – I made a one-liner command you can copy paste into your SSH terminal that attempts to do all of these things in 1 go.
I use a –keep-generated flag because I’ve noticed Magento losing all of the static files while generating static files – meaning your site will go down! I am not sure if anyone else has noticed that. But the flag protects me from that behaviour.
I generally run this command after installing a module, or making big changes to the theme, or when Magento’s not really running as it should. Here it is:
php bin/magento setup:upgrade --keep-generated && php bin/magento setup:di:compile && php bin/magento setup:static-content:deploy --language en_AU --language en_US && php bin/magento indexer:reindex && php bin/magento cache:clean && php bin/magento cache:flush
The multiple –language params reflect my needs – I generally have clients in Australia so I need en_AU but en_US seems quite mandatory most of the cases so even though it takes almost twice as long, I need to generate these local copies.
Let me in the comments know how you go and/or if you have issues running this a particular Magento version!