4

I have a Magento 2 store in "production mode"

My question is, If I want to change a phtml file, do I need to change to developer mode or is it enough to execute setup:static-content:deploy -f?

  • Enable developer mode only when you want to see error on the screen. – i_ali55 Apr 22 at 11:14
  • and after changing in phtml file you dont need to run deploy command. Just clean the cache and thats it. – i_ali55 Apr 22 at 11:14
  • So when I change a phtml file I just need to execute setup:static-content:deploy -f to get results? – Make UP Apr 22 at 11:15
  • I did but the changes does not appear ? I use a custom theme – Make UP Apr 22 at 11:16
  • 1
    Aaditya thank you very much for your help. So I should always change to developer mode change the phtml file and then change back to production mode ? This is really annoying. – Make UP Apr 22 at 11:32
2

In production mode you can directly run static deploy command so you don't need to add -f in your command.

There is no need to change developer mode on production environment every time you change in phtml. Just run static deploy command and it will work fine.

For production:

php bin/magento setup:static-content:deploy

For development:

php bin/magento setup:static-content:deploy -f
  • 3
    In Developer mode -f is used it means forceful deployment. no need to add -f in production mode – Sairaj Gadekar Apr 22 at 11:55
3

Production mode :

  • If you are in Production mode and you made any change in PHTML file or any view files then it requires running the deploy tool again.
  • In this mode, static view files are not created on the fly when they are requested; instead, they have to be deployed to the pub/static directory using the command-line tool.

Developer mode :

  • If you make any change in PHTML file or any view files are immediately visible.

  • Uncaught exceptions and errors displayed in the web browser.

  • Automatic code compilation.

Deploy static view files

php bin/magento setup:static-content:deploy

But to deploy static view files for the en_US language, command must be like this:

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

Command options:

bin/magento setup:static-content:deploy [<languages>] [-t|--theme[="<theme>"]] [--exclude-theme[="<theme>"]] [-l|--language[="<language>"]] [--exclude-language[="<language>"]] [-a|--area[="<area>"]] [--exclude-area[="<area>"]] [-j|--jobs[="<number>"]]  [--no-javascript] [--no-css] [--no-less] [--no-images] [--no-fonts] [--no-html] [--no-misc] [--no-html-minify] [-f|--force]

My question is, If I want to change a phtml file, do I need to change to developer mode or is it enough to execute setup:static-content:deploy -f?


You should use the Developer mode while you are developing. In Developer mode, static view files are generated every time they are requested.

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.