tiger-seo / PhpBuiltinServer

Codeception extension for starting and stopping php built-in server
38 stars 35 forks source link

Option to disable directory index routing #9

Open grantlucas opened 10 years ago

grantlucas commented 10 years ago

In some frameworks, passing index.php, or the directory index back from the router would cause "/" to fail to load a page since it's passing back the output of the directory index.

Some frameworks, like Zend Framework 1 don't behave properly when index.php is passed back.

This adds false detection to directoryIndex configuration parameter. The values passed to the router is noDirectoryIndex since off was getting converted to an empty string.

grantlucas commented 10 years ago

Any word on the possibility of incorporating some of the open Pull Requests? Thanks. :smile:

cooperaj commented 9 years ago

This issue is affecting me when using Bolt CMS (a Silex application) disabling the routing in the code allows my '/' tests to pass. Leaving it in gives require_once errors on the vendor/autoload.php file.

tiger-seo commented 9 years ago

maybe instead of new parameter would be better to add a special case for directoryIndex, e.g. in codeception.yml: directoryIndex: false or directoryIndex: ~ ?

cooperaj commented 9 years ago

@tiger-seo This makes sense. I'd be happy with that as an option.

grantlucas commented 9 years ago

@tiger-seo I tried messing with it a bit to update this PR to match your recommendation but am having an issue.

Because of this using ~ and just not having the config value in the file both result in codecept.directory_index becoming false.

A way around this would be to use false as the codeception.yml value and then check for an empty string in Router.php.

Any idea what's going on here? Is Codeception converting the configuration data?

Thanks.

tiger-seo commented 9 years ago

A way around this would be to use false as the codeception.yml value and then check for an empty string in Router.php.

yes, first of all it should be readable and understandable for users so, in codeception.yml it is good to have it like directoryIndex: false, but then pass it to php.exe like -dcodecept.directory_index=off and check if ini_get(codecept.directory_index) === 'off' then we don't use directoryIndex

grantlucas commented 9 years ago

:+1: sounds good to me. Will work on that patch

tiger-seo commented 9 years ago

fantastic :+1: thanks

grantlucas commented 9 years ago

@tiger-seo This PR has been updated to match your recommendation. Only issue I ran into was that off was getting converted to an empty string when passing it through -dcodecept.directory_index. I used noDirectoryIndex instead and that seems to work.

Let me know if this works for you or if you'd like any changes.