hoaproject / Router

The Hoa\Router library.
https://hoa-project.net/
28 stars 11 forks source link

Automatically set the prefix for `Hoa\Router\Http` #3

Closed Hywan closed 11 years ago

Hywan commented 11 years ago

Hello,

It would be great to have a magic way to autoset the prefix. Indeed, it's annoying if the user always needs to call the Hoa\Router\Http::setPrefix each time he is moving an application or changing server configuration.

On Apache, we can use the $_SERVER['SCRIPT_NAME'] value but it does not work with the PHP internal Web server. Does it work with other Web servers?

Any other ideas?

Hywan commented 11 years ago

Note: https://bugs.php.net/bug.php?id=64951.

osaris commented 11 years ago

I tested with nginx and php-fpm. I'm calling http://test.imagineapp.com/foo/bar/ and here is the output for $_SERVER['SCRIPT_NAME'] : [SCRIPT_NAME] => /foo/bar/index.php

If I call http://test.imagineapp.com/foo/bar/bar/baz with rewritting enabled, the result is the same.

So it seems that the content of $_SERVER['SCRIPT_NAME'] is the same for apache and nginx.

hoaproject commented 11 years ago

Thanks!

hoaproject commented 11 years ago

Done 2897e77fadcf40567acf07f869d634b65091c67b.