Magento 2 Editing phtml files in Production Mode

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.


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