layout | group | subgroup | title | menu_title | menu_node | menu_order | version | github_link |
---|---|---|---|---|---|---|---|---|
default |
config-guide |
04_CLI |
Set the Magento mode |
Set the Magento mode |
200 |
2.0 |
config-guide/cli/config-cli-subcommands-mode.md |
Production mode also has better performance because static view files are populated in the pub/static
directory and because of code compilation.
- In version 2.0.6 and later, Magento does not explicitly set file or directory permissions when you switch between default, develop, and production modes.
- Unlike other Magento modes, developer and production modes are set in
env.php
.
For more information about Magento file system ownership and permissions, see Magento ownership and permissions in development and production.
When you change to developer or production mode, we clear the contents of following directories:
var/cache
var/di
var/generation
var/view_preprocessed
pub/static
Exceptions:
.htaccess
files are not removedpub/static
contains a file that specifies the version of static content; this file is not removed
By default, Magento uses the var
directories to store the cache, logs, and compiled code. You can customize this directory but in this guide, it's assumed to be var
.
Command usage:
magento deploy:mode:show
A message similar to the following displays:
Current application mode: developer.
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.
You cannot currently change from either developer or production mode to default mode.
Examples follow.
magento deploy:mode:set production
Following is a summary of messages that display:
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 {% glossarytooltip 45f1f76d-91cd-4789-a8b5-1e3f321a6280 %}SASS{% endglossarytooltip %} files {% glossarytooltip 6c5cb4e9-9197-46f2-ba79-6147d9bfe66d %}CSS{% endglossarytooltip %} 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.
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
andvar/di
directories:rm -rf <your Magento install dir>/var/di/* <your Magento install dir>/var/generation/*
-
Set the mode:
magento deploy:mode:set developer
The following message displays:
Switched to developer mode.