This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Fabien Potencier 3f44bba01e merged branch ajessu/php54-server-fix (PR #4484)
Commits
-------

d982bac Fix built-in server for PHP > 5.4.1

Discussion
----------

[FrameworkBundle] Fix built-in server command for PHP > 5.4.1

Bug fix: yes
Feature addition: no
Backwards compatibility break: yes
Symfony2 tests pass: yes

License of the code: MIT

The router isn't routing with PHP > 5.4.1, unless you explicitly include the name of the controller.

For the default command: `app/console server:run`

localhost:8000/app_dev.php `Works`
localhost:8000/ `Doesn't work (it used to work on PHP 5.4.0`)

There was a change after PHP 5.4.1 which makes the router from the built-in server command not work, when no resource is specified, as the variable `$_SERVER['SCRIPT_FILENAME']` passes the `isset` check.

Changelog: http://php.net/ChangeLog-5.php#5.4.1
- Implemented #60850 (Built in web server does not set $_SERVER['SCRIPT_FILENAME'] when using router)

The `router` used to rely on the `$_SERVER['SCRIPT_FILENAME']` being set, to return any asset/file if it existed.

This behavior was changed, so that when using PHP's built-in server, the `$_SERVER['SCRIPT_FILENAME']` is now populated with a combination of the document root and the router filename
Patch: https://bugs.php.net/patch-display.php?bug_id=60850&patch=add_router_script_file_name_svr_var&revision=latest)

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

by travisbot at 2012-06-02T09:06:05Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1506479) (merged b85ff7dd into 1541fe26).

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

by ajessu at 2012-06-03T07:16:33Z

Thinking a bit more about this, as I find my solution a bit weird.

I'll do a bit more testing and report back.

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

by fabpot at 2012-06-13T14:30:28Z

Any news on this PR?

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

by travisbot at 2012-06-18T21:20:17Z

This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1650548) (merged d982bac0 into 086ff482).

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

by ajessu at 2012-06-18T21:35:44Z

Updated the solution, and for me, it's ready to be merged now.

I talked about this on Symfony Live with @michal-pipa (the original contributor to this command) and we were trying to avoid touching the filesystem for the check of file existance to skip the server, but I don't think there is any other way (and it's dev mode, it really shouldn't matter much either).

PHP 5.4.1 and up has changed the behavior of `$_SERVER['SCRIPT_FILENAME']` for the built-in server and it's a bit unreliable/ugly to rely on it now.

This fixes the command, it works again for all versions of PHP 5.4.x
A very similar solution was also suggested on internals:
http://news.php.net/php.internals/53870

@michal-pipa any other ideas?

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

by michal-pipa at 2012-06-18T23:14:36Z

I'll take a closer look at this tomorrow.

But I think that you should revert to original behavior and call production front controller by default to be consistent with other servers.

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

by ajessu at 2012-06-19T08:48:17Z

> But I think that you should revert to original behavior and call production front controller by default to be consistent with other servers.

I disagree. This is a development-only server, and thus, the development controller should be called since IMHO it will be the most common use case for the command, development.
If for some reason, someone wants to use their production controller, it's as easy as providing a new router and passing it to the command explicitly.

Let me know if you come up with something else.
2012-06-19 10:56:44 +02:00
src/Symfony merged branch ajessu/php54-server-fix (PR #4484) 2012-06-19 10:56:44 +02:00
.editorconfig Add EditorConfig File 2012-06-16 14:08:15 +02:00
.gitignore ignore composer.phar 2012-04-20 14:10:06 +01:00
.travis.yml merged 2.0 2012-05-30 13:44:37 +02:00
autoload.php.dist [Propel1] Removed useless require in autoload.php.dist 2012-04-20 09:46:34 +02:00
CHANGELOG-2.0.md updated CHANGELOG for 2.0.14 2012-05-17 18:29:55 +02:00
composer.json Added missing dependency to doctrine common in the global composer.json 2012-05-20 22:32:48 +02:00
CONTRIBUTORS.md update CONTRIBUTORS for 2.0.14 2012-05-17 18:30:22 +02:00
LICENSE Updated LICENSE files copyright 2012-02-22 10:10:37 +01:00
phpunit.xml.dist Set init.default_locale to 'en' in phpunit.xml.dist 2012-05-11 09:33:42 +02:00
README.md updated minimum PHP version to 5.3.3 2012-05-07 10:29:11 +02:00
UPGRADE-2.1.md tweaked UPGRADE file 2012-06-16 19:50:09 +03:00

README

Build Status

What is Symfony2?

Symfony2 is a PHP 5.3 full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP.

Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers.

Requirements

Symfony2 is only supported on PHP 5.3.3 and up.

Installation

The best way to install Symfony2 is to download the Symfony Standard Edition available at http://symfony.com/download.

Documentation

The "Quick Tour" tutorial gives you a first feeling of the framework. If, like us, you think that Symfony2 can help speed up your development and take the quality of your work to the next level, read the official Symfony2 documentation.

Contributing

Symfony2 is an open source, community-driven project. If you'd like to contribute, please read the Contributing Code part of the documentation. If you're submitting a pull request, please follow the guidelines in the Submitting a Patch section.