[FrameworkBundle] Fix built-in server when using query params in paths

$_SERVER['REQUEST_URI'] will contain the query params so is_file will fail.
Change it to use $_SERVER['SCRIPT_NAME'] instead which only contains the
relative filename of the the script.
merged branch flojon/patch-1 (PR #4638)

Commits
-------

eb26e89 [FrameworkBundle] Fix built-in server when using query params in paths

Discussion
----------

[FrameworkBundle] Fix built-in server when using query params in paths

$_SERVER['REQUEST_URI'] will contain the query params so is_file will fail.
I propose to use $_SERVER['SCRIPT_FILENAME'] instead which contains the full path and no query params.

---------------------------------------------------------------------------

by ajessu at 2012-06-23T10:17:34Z

I was going to make this comment on your approach in #4484, but I'll make it here, since that issue is already closed.

Your solution won't work on PHP 5.4.0, as `$_SERVER['SCRIPT_FILENAME']` will not be set [see PHP bug #60850](https://bugs.php.net/bug.php?id=60850).

Also PHP 5.4.1 and up, if you don't request a file explicitely, Ex:

     http://localhost:8000/app_dev.php

but a location, Ex:

    http://localhost:8000/

The value of the `$_SERVER['SCRIPT_FILENAME']` will be the router file, not the script name, which makes relying on `$_SERVER['SCRIPT_FILENAME']` inconsistent. [See this comment on the php bug](https://bugs.php.net/bug.php?id=60850#1331261652)

I'm not sure if (nor how?) the issue of the params should be addressed on this "default" router, to not make it overly complex.

For your use case, and this is just my own early opinion without much thought, in case we can't come up with a general solution, there is always the option of defining your own router and passing it to the `server:run` command with `--router` like so:

    php app/console server:run --router=app/config/my_own_router.php

---------------------------------------------------------------------------

by flojon at 2012-06-23T10:31:47Z

So would `$_SERVER['SCRIPT_NAME']` be more reliable? Like this:

    if (is_file($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $_SERVER['SCRIPT_NAME'])) {
        return false;
    }

I did a simple test and `$_SERVER['SCRIPT_NAME']` is set to `/` when accessing the root (using PHP 5.4.3).

---------------------------------------------------------------------------

by flojon at 2012-06-23T10:51:22Z

Browse around the code a bit and `$_SERVER['SCRIPT_NAME']` has been there since PHP 5.4.0:
https://github.com/php/php-src/blob/php-5.4.0/sapi/cli/php_cli_server.c#L598

---------------------------------------------------------------------------

by travisbot at 2012-06-23T11:16:59Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1688361) (merged eb26e896 into 0d4b02e4).

---------------------------------------------------------------------------

by travisbot at 2012-06-24T10:23:52Z

This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1688043) (merged 71855665 into 0d4b02e4).

---------------------------------------------------------------------------

by CHH at 2012-06-29T07:17:32Z

This works fine for me!

:+1:

Could someone please merge this? This issue makes the `server:run` command currently quite unusable, because it can't load CSS for example which has a `?v=` parameter.

---------------------------------------------------------------------------

by ajessu at 2012-06-29T08:25:14Z

:+1: from me also. Works just like `$_SERVER['REQUEST_URI']`, but doesn't include the params.

Tested working on PHP 5.4.0 and 5.4.3.