PhpBuiltinServer icon indicating copy to clipboard operation
PhpBuiltinServer copied to clipboard

Option to disable directory index routing

Open grantlucas opened this issue 11 years ago • 9 comments

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 avatar Jul 08 '14 17:07 grantlucas

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

grantlucas avatar Jul 28 '14 13:07 grantlucas

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.

cooperaj avatar Apr 20 '15 13:04 cooperaj

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

tiger-seo avatar Apr 22 '15 17:04 tiger-seo

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

cooperaj avatar Apr 22 '15 17:04 cooperaj

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

  • Whenever ~ is used as a value, it "should" be considered nil by Yaml standards but it ends up as false
  • If I pass in false for directoryIndex, the resulting config value is an empty string.

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.

grantlucas avatar Apr 22 '15 20:04 grantlucas

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

tiger-seo avatar Apr 23 '15 12:04 tiger-seo

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

grantlucas avatar Apr 23 '15 12:04 grantlucas

fantastic :+1: thanks

tiger-seo avatar Apr 23 '15 12:04 tiger-seo

@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.

grantlucas avatar Apr 23 '15 14:04 grantlucas