• <tfoot id='QslhS'></tfoot>

    1. <legend id='QslhS'><style id='QslhS'><dir id='QslhS'><q id='QslhS'></q></dir></style></legend>

        <bdo id='QslhS'></bdo><ul id='QslhS'></ul>

        <small id='QslhS'></small><noframes id='QslhS'>

        <i id='QslhS'><tr id='QslhS'><dt id='QslhS'><q id='QslhS'><span id='QslhS'><b id='QslhS'><form id='QslhS'><ins id='QslhS'></ins><ul id='QslhS'></ul><sub id='QslhS'></sub></form><legend id='QslhS'></legend><bdo id='QslhS'><pre id='QslhS'><center id='QslhS'></center></pre></bdo></b><th id='QslhS'></th></span></q></dt></tr></i><div id='QslhS'><tfoot id='QslhS'></tfoot><dl id='QslhS'><fieldset id='QslhS'></fieldset></dl></div>

      1. 检查是否在“开发"中带 Symfony 的控制器内的模式

        Check if in quot;devquot; mode inside a Controller with Symfony(检查是否在“开发中带 Symfony 的控制器内的模式)
      2. <i id='Ac30x'><tr id='Ac30x'><dt id='Ac30x'><q id='Ac30x'><span id='Ac30x'><b id='Ac30x'><form id='Ac30x'><ins id='Ac30x'></ins><ul id='Ac30x'></ul><sub id='Ac30x'></sub></form><legend id='Ac30x'></legend><bdo id='Ac30x'><pre id='Ac30x'><center id='Ac30x'></center></pre></bdo></b><th id='Ac30x'></th></span></q></dt></tr></i><div id='Ac30x'><tfoot id='Ac30x'></tfoot><dl id='Ac30x'><fieldset id='Ac30x'></fieldset></dl></div>
            <tbody id='Ac30x'></tbody>

          <small id='Ac30x'></small><noframes id='Ac30x'>

            • <bdo id='Ac30x'></bdo><ul id='Ac30x'></ul>
              <legend id='Ac30x'><style id='Ac30x'><dir id='Ac30x'><q id='Ac30x'></q></dir></style></legend>

                  <tfoot id='Ac30x'></tfoot>
                  本文介绍了检查是否在“开发"中带 Symfony 的控制器内的模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Symfony2.x 应用程序中使用开发模式时,通常在语言环境中工作.因此,此类功能无法按预期工作(例如,尝试获取 localhost 下的当前 IP).这可能是一个问题,例如当您尝试使用这种基于 ip 的网络服务时.因此,我只想知道如何在控制器内部检查 Symfony2 应用程序是否在 dev 模式下运行.这样就可以根据模式设置控制器的行为.

                  When using dev mode with a Symfony2.x application, one usually works in locale. Hence, such function does not works as expected (for instance, try to get the current IP under localhost). This could be a problem, e.g. when one try to use such ip-based web service. Hence, I just want to know how to check inside a controller if the Symfony2 application is running in dev mode or not. In that way one can set the behavior of the controller depending by the mode.

                  有什么想法吗?

                  推荐答案

                  要在 Controller 中获取当前环境,您可以使用:

                  To get the current environment in a Controller you can use:

                  $this->container->getParameter('kernel.environment');
                  

                  所以你只要把它放在一个 if() 语句中来检查它是否等于 dev.

                  So you just put that in an if() statement to check if it equals to dev.

                  这篇关于检查是否在“开发"中带 Symfony 的控制器内的模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
                1. <legend id='R4ki6'><style id='R4ki6'><dir id='R4ki6'><q id='R4ki6'></q></dir></style></legend>
                  • <tfoot id='R4ki6'></tfoot>

                          <tbody id='R4ki6'></tbody>
                          <i id='R4ki6'><tr id='R4ki6'><dt id='R4ki6'><q id='R4ki6'><span id='R4ki6'><b id='R4ki6'><form id='R4ki6'><ins id='R4ki6'></ins><ul id='R4ki6'></ul><sub id='R4ki6'></sub></form><legend id='R4ki6'></legend><bdo id='R4ki6'><pre id='R4ki6'><center id='R4ki6'></center></pre></bdo></b><th id='R4ki6'></th></span></q></dt></tr></i><div id='R4ki6'><tfoot id='R4ki6'></tfoot><dl id='R4ki6'><fieldset id='R4ki6'></fieldset></dl></div>

                          <small id='R4ki6'></small><noframes id='R4ki6'>

                            <bdo id='R4ki6'></bdo><ul id='R4ki6'></ul>