TransWikia.com

Any Drawback on running setup:upgrade, di:compile, static deploy everytime code level edit on Magento 2

Magento Asked by Shailesh on November 8, 2021

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/

2 Answers

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

and

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.

Answered by L. Gerhardt on November 8, 2021

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.

Answered by Denlier1211 on November 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP