Description
Symfony version(s) affected: >=4.4
(IIS version: 10.0.19041.332 on Windows 10)
Description
Since 4.4 it seems not possible to run a symfony application with IIS (no issues with 4.3 except the problem described in #36413). I stumbled over it when trying to upgrade my application, but the problem also occurs with a very simple setup.
You would expect the output Lucky number: 40
but you will only get [info] Matched route "app_lucky_number".
How to reproduce
Execute composer create-project symfony/skeleton=4.4.99 test
and then just add the controller and route as described here: https://symfony.com/doc/current/page_creation.html
<?php
// src/Controller/LuckyController.php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
class LuckyController
{
public function number(): Response
{
$number = random_int(0, 100);
return new Response(
'<html><body>Lucky number: '.$number.'</body></html>'
);
}
}
# config/routes.yaml
# the "app_lucky_number" route name is not important yet
app_lucky_number:
path: /lucky/number
controller: App\Controller\LuckyController::number
You will also need a web.config
file for url rewrite (see Additional context).
If you start with composer create-project symfony/skeleton=4.3.99 test
instead of 4.4.99
it will work without a problem. It will also work with APP_ENV=prod
instead of APP_ENV=dev
so it seems to have something to do with the environment.
Additional context
To run symfony on IIS I created a /public/web.config
file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Rewrite for Symfony" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Any idea what's causing this problem?