-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Config\Factory can read from include_path #4574
Config\Factory can read from include_path #4574
Conversation
Why exactly would you include configuration from the include path. More like, why would you not know where the config files are located? This is kinda the same as the translation loaders loading from the include_path – there I couldn't really understand the true use case either, especially not since the include_path is not meant for non-PHP files. |
It's because whole application is in PHAR, so I can have relative config_static_paths. chdir does not work on PHAR, otherwise no problem. Same about translations. And from my point of view it's a feature, because doesn't matter the file path is relative to the file system or within an include path of PHAR. You can PHAR entire application and it works. |
@bacinsky I don't think this feature is needed because it's focused on a specific use case that actually can be manageable in a different way. You can manage relative path in a PHAR project but you have to refer to the path of the PHAR file. For more example on that you can check this post: http://mangstacular.blogspot.it/2011/06/php-relative-paths-and-phar-archives.html |
The only problem in Config\Factory is that exception before include. It lies. But whatever... |
@@ -65,7 +65,14 @@ class Factory | |||
*/ | |||
public static function fromFile($filename, $returnConfigObject = false) | |||
{ | |||
$pathinfo = pathinfo($filename); | |||
$fromIncludePath = stream_resolve_include_path($filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't do this unless !file_exists($filename)
, as stream_resolve_include_path()
can be quite expensive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change on merge.
…om-include-path Config\Factory can read from include_path
- i.e., when `file_exists()` fails - Raise an exception if it still cannot be found
…ture/config-factory-read-from-include-path Config\Factory can read from include_path
…th when necessary - i.e., when `file_exists()` fails - Raise an exception if it still cannot be found
Added possibility to load config files from the include path.