Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/sbboke.com/wp-content/plugins/wordpress-seo/src/integrations/front-end-integration.php:409) in /www/wwwroot/sbboke.com/wp-content/themes/pacify/content-single.php on line 5

Magento 2启用禁用开发者模式

Magento 2平台为用户提供三种模式,即默认模式,开发人员模式和生产模式。根据具体情况,商店管理员可以为其Magento商店应用不同的模式。

在今天的帖子中,我将为您提供有关Magento 2开发人员模式的基本知识,以及可用于启用和禁用它的方法。

在Magento 2中启用禁用开发者模式

  • 什么是开发者模式
  • 检查当前模式
  • 启用开发者模式
  • 禁用开发者模式

什么是开发者模式

Magento的开发人员模式是您在需要自定义Magento 2或要安装扩展时使用的模式。更具体地说,它将用于以下情况:

  • 将每个所需文件的符号链接发布到pub / static目录
  • 浏览器中可以看到未捕获的异常
  • 登录var / report的系统是口头的。将异常放入错误处理程序中
  • 如果无法强制执行事件订阅者,则生成异常。

检查当前模式

要检查当前模式,需要以Magento文件系统所有者身份运行以下命令:

bin/magento deploy:mode:show

如果您有共享主机,那么这将是您的提供商为您提供登录服务器的用户。相反,如果您的服务器是私有的,则它是Magento服务器上的本地用户帐户。

运行上述命令后,将显示与此类似的消息:

Current application mode: {mode}. 

注意:环境变量可能会覆盖此值。而{mode}可以defaultdeveloperproduction

启用开发者模式

在启用开发者模式之前,您需要确保生成的类和对象管理器实体(如代理)已清除。否则,可能会发生意外错误。清除它们后,您可以按照以下步骤开始将模式从生产更改为开发人员:

  • 步骤1:在第一步中,删除生成的/代码和生成的/元数据目录的内容:
rm -rf <your Magento install dir>/generated/metadata/* <your Magento install dir>/generated/code/*
  • 第2步:接下来,您可以设置模式:
bin/magento deploy:mode:set developer

设置模式后,您将看到以下消息:

Enabled developer mode.

禁用开发者模式

上面我刚刚向您展示了启用Developer模式的方法。但是,在各种情况下,您需要将模式从开发人员更改为生产。这就是你如何做到的:

首先,将模式设置为Production。

bin/magento deploy:mode:set production

设置模式后,您将看到与此类似的消息:

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   <span term-uuid="45f1f76d-91cd-4789-a8b5-1e3f321a6280" class="glossary-term" data-toggle="popover">Sass</span>  files   <span term-uuid="6c5cb4e9-9197-46f2-ba79-6147d9bfe66d" class="glossary-term" data-toggle="popover">CSS</span>  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.

结论

总之,Magento 2平台提供的开发者模式对于各种特定情况下的商店所有者来说至关重要。我希望上述信息可以为您提供激活和停用开发者模式的必要细节。

相关文章

0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论