IIS服务器10上的Symfony 6:路由获取的是日志,而不是端点的结果

k4ymrczo  于 2023-08-05  发布在  其他
关注(0)|答案(1)|浏览(96)

我试图把我的应用程序与symfony 6和API平台3上的IIS服务器。在本地主机上没有问题。在/API上,我可以获取文档,也可以调用我的端点。但是当我调用我的API的在线版本时,我得到的是一种日志,而不是我的端点的结果。

[info] Matched route "api_entrypoint".
[debug] Checking for authenticator support.
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
[debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ValidateRequestListener::onKernelRequest".
[debug] Notified event "kernel.request" to listener "Nelmio\CorsBundle\EventListener\CorsListener::onKernelRequest".
...

字符串
我的网站点在公共文件中,在index.php上。我试过很多web.config,实际上我用的是这个:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="index.php" />
            </files>
        </defaultDocument>
    <rewrite>
         <rules>
        <rule name="Rewriter" stopProcessing="true">
            <match url="^(.*)$" ignoreCase="false" />
            <conditions>
                <add input="{R:1}" pattern="^(index\\.php|favicon\\.ico)" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            </conditions>
            <action type="Rewrite" url="./index.php/{R:1}" appendQueryString="true" />
        </rule>
        </rules>
        </rewrite>
    </system.webServer>
</configuration>


我的端点被识别,只是结果不是我所期望的,日志而不是EP的json结果。

of1yzvn4

of1yzvn41#

我遇到了同样的问题,虽然我不确定是什么导致了这个问题,但我通过以下步骤解决了这个问题。我想我应该和你分享一下,也许会有帮助:
1.当我试图在本地计算机上的IIS中部署我的项目时,我必须调整“my_project”文件夹的安全设置,这解决了这个问题。
1.然而,当我尝试在真实的服务器上部署项目时,我应用了相同的安全设置,但它不起作用。经过进一步的故障排除,我发现使用命令“composer require Symfony/monolog-bundle”添加“Symfony/monolog-bundle”包可以使一切正常工作。
我知道问题的根本原因可能因不同的情况而异。但由于这个解决方案对我来说很有效,当我在网上苦苦寻找任何答案时,我想与你分享这些步骤。
希望这对你有帮助!

相关问题