Is it ok to run the following set of commands by default everytime I make a code level edit (layout edits, module creation, extension update)

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static:content:deploy -f
php bin/magento c:f
find var generated vendor pub/static pub/media app/etc -type f -exec chmod u+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod u+w {} + && chmod u+x bin/magento

I believe that not all edits require, setup upgrade or di:compile. But, does running all above set of commands even if not required cause any issue.

EDIT: Should not use 777

chmod -R 777 generated/ var/ pub/
  • what mode you are using ? – Pawan Jul 7 '20 at 6:43
  • the only problem you will face is when magento regenerate those new files then again you need to setup permission after running these commands since you will no longer own those files – Pramod Jul 7 '20 at 6:50
  • @Pawan default. (if you are asking for setup deploy.. yes, its not required in default mode, but asking if any issue, if i run all of them) – Shailesh Jul 10 '20 at 4:47
  • @Chikku hmm.. so I should also include the ownership command at the end? – Shailesh Jul 10 '20 at 4:48
  • yep thats right – Pramod Jul 10 '20 at 5:12

Generally, we don't need to run every command all the time. Sometimes it only requires cache: flush but extension creation or enabling any extension needs every command. Not an issue if you're running these command unnecessarily except changing permission, but It's wasting of time, and mainly if the site is live, then it stops working until commands executed. While in chmod command, it grants permission, so it's recommended not to use that command without requirement because every permission setting of a file is for security purpose.

  • Thanks for pointing that out. is the following proper? [code]find var generated vendor pub/static pub/media app/etc -type f -exec chmod u+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod u+w {} + && chmod u+x bin/magento[/code] – Shailesh Jul 10 '20 at 4:58

I recommend that you check out the documentation on each of the commands or just run

php bin/magento help

to see a list of available cli commands and their purposes. Depending on the mode you are using for your installation you might not require to run anything other than

php bin/magento setup:upgrade


php bin/magento c:f

most of the time. If you change any di.xml file, run

php bin/magento setup:di:compile

and if you are not in developer mode, changes to *.html and *.js files will require

php bin/magento setup:static-content:deploy -f

to take effect.
Should not be required at all after running it once - at least when your webserver's user configuration is correct:

chmod -R 777 generated/ var/ pub/

Especially di.xml compilation and static content deploy can take quite some time on a dev machine, so better not run them if it's not necessary.

  • Yes, commands required to be run depend on the changes made in Magento. But, I'm asking is there any issue if I run all the commands anyhow everytime.. – Shailesh Jul 10 '20 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.