Difference between revisions of "How to Change Magento 2 mode"
(Created page with "==How to Change Magento 2 mode (Default, Production, Development)== ===Display the Current Mode=== The easiest way to do that is to run this command as the Magento file syst...") |
(No difference)
|
Latest revision as of 19:17, 2 November 2018
Contents
How to Change Magento 2 mode (Default, Production, Development)
Display the Current Mode
The easiest way to do that is to run this command as the Magento file system owner. If you have shared hosting, this is the user your provider gives you to log in to the server. If you have a private server, it’s typically a local user account on the Magento server.
bin/magento deploy:mode:show
You then get a message letting you the current mode
Current application mode: developer.
Magento 2 Change Modes
Below is the basic syntax for changing the Magento 2 mode
bin/magento deploy:mode:set {mode} [-s|--skip-compilation]
Where:
{mode} is required; it can be either developer or production
--skip-compilation is an optional parameter you can use to skip code compilation when you change to production mode.
With that being stated, lets show an example of changing your site to developer and production
Change to production mode
bin/magento deploy:mode:set production
You then see status as it switches the site over to production, example:
Enabled maintenance mode Requested languages: en_US === frontend -> Magento/luma -> en_US === ... more ... Successful: 1884 files; errors: 0 --- === frontend -> Magento/blank -> en_US === ... more ... Successful: 1828 files; errors: 0 --- === adminhtml -> Magento/backend -> en_US === ... more ... --- === Minify templates === ... more ... Successful: 897 files modified --- New version of deployed files: 1440461332 Static content deployment complete Gathering css/styles-m.less sources. Successfully processed LESS and/or Sass files CSS deployment complete Generated classes: Magento\Sales\Api\Data\CreditmemoCommentInterfacePersistor Magento\Sales\Api\Data\CreditmemoCommentInterfaceFactory Magento\Sales\Api\Data\CreditmemoCommentSearchResultInterfaceFactory Magento\Sales\Api\Data\CreditmemoComment\Repository Magento\Sales\Api\Data\CreditmemoItemInterfacePersistor ... more ... Compilation complete Disabled maintenance mode Enabled production mode.
Change to developer mode
When you change from production to developer mode, you should clear generated classes and Object Manager entities like proxies to prevent unexpected errors. After doing so, you can change modes. Use the following steps:
If you’re changing from production mode to developer mode, delete the contents of the var/generation and var/di directories:
rm -rf <your Magento install dir>/var/di/* <your Magento install dir>/var/generation/*
Set the mode:
bin/magento deploy:mode:set developer
The following message displays:
Switched to developer mode.
Special Note:
Once you switch from default mode you can not switch back to it, it has be production or developer