Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Config\Factory can read from include_path #4574

Conversation

bacinsky
Copy link
Contributor

@bacinsky bacinsky commented Jun 2, 2013

Added possibility to load config files from the include path.

@DASPRiD
Copy link
Member

DASPRiD commented Jun 6, 2013

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.

@bacinsky
Copy link
Contributor Author

bacinsky commented Jun 6, 2013

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.

@ezimuel
Copy link
Contributor

ezimuel commented Jun 6, 2013

@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

@ezimuel ezimuel closed this Jun 6, 2013
@bacinsky
Copy link
Contributor Author

bacinsky commented Jun 6, 2013

The only problem in Config\Factory is that exception before include. It lies. But whatever...

@DASPRiD
Copy link
Member

DASPRiD commented Jun 6, 2013

@ezimuel I guess we could close #4515 for the same reason?

@ezimuel
Copy link
Contributor

ezimuel commented Jun 6, 2013

@bacinsky Ok, it seems that this issue is also related with #4515. I'm reopening it to spend more time on it and double check. @DASPRiD thanks for your advice.

@ezimuel ezimuel reopened this Jun 6, 2013
@@ -65,7 +65,14 @@ class Factory
*/
public static function fromFile($filename, $returnConfigObject = false)
{
$pathinfo = pathinfo($filename);
$fromIncludePath = stream_resolve_include_path($filename);
Copy link
Member

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.

Copy link
Member

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.

weierophinney added a commit that referenced this pull request Jun 28, 2013
…om-include-path

Config\Factory can read from include_path
weierophinney added a commit that referenced this pull request Jun 28, 2013
- i.e., when `file_exists()` fails
- Raise an exception if it still cannot be found
weierophinney added a commit that referenced this pull request Jun 28, 2013
@weierophinney weierophinney merged commit 5c204ed into zendframework:develop Jun 28, 2013
@ghost ghost assigned weierophinney Jun 28, 2013
@bacinsky bacinsky deleted the feature/config-factory-read-from-include-path branch June 28, 2013 13:32
weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015
…ture/config-factory-read-from-include-path

Config\Factory can read from include_path
weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015
…th when necessary

- i.e., when `file_exists()` fails
- Raise an exception if it still cannot be found
weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants