Option to disable directory index routing
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.
Any word on the possibility of incorporating some of the open Pull Requests? Thanks. :smile:
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.
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 This makes sense. I'd be happy with that as an option.
@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 considerednilby Yaml standards but it ends up asfalse - If I pass in
falsefordirectoryIndex, 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.
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
:+1: sounds good to me. Will work on that patch
fantastic :+1: thanks
@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.