Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert filenames to SplFileInfo objects #35

Closed
electricjones opened this issue Nov 3, 2015 · 8 comments
Closed

Convert filenames to SplFileInfo objects #35

electricjones opened this issue Nov 3, 2015 · 8 comments
Milestone

Comments

@electricjones
Copy link
Owner

As it stands, the user MUST pass an instance of SplFileInfo into the FileLoader. This is good, but it should be easy enough to add a little magic to this:

$manager->loadFiles([
   __DIR__ . '/my/file.json',
   __DIR__ . '/my/file.php',
]);

This would apply to the LoadsFilesTrait and the FileLoader itself, though it may be best to do the actual work in FileBag and just pass values down to that.

@electricjones electricjones added this to the v0.8.7 milestone Nov 3, 2015
This was referenced Nov 3, 2015
@smolinari
Copy link
Contributor

To get this working, we'd have to involve something like Symfony/finder (or parts of it). Finder offers a lot of extra functionality, which might be overkill, but in the end, it delivers an easy way to point to a config file directory (or directories) and get SPLFileInfo results for all of the files in those directories.

From a usability perspective, I'd also think pointing to directories and saying "go get anything in them and load them", is the simplest solution. Obviously, single files should also be "loadable".

https://github.com/symfony/Finder

Scott

@electricjones
Copy link
Owner Author

I didn't mean something so complex. I just meant "take the string with a filepath and swap it for an SplFileInfo object with that same file. Not a finder or recursive thing. They can already use Finder optionally for that. What I'm thinking would really only be a few lines of code 😸

@smolinari
Copy link
Contributor

Sure. But again, to me, from a user perspective, the input should be a directory path holding any number of config files. That would be simpler, more user friendly.

$manager->loadFiles([
   __DIR__ . '/myConfigFilePath1',
   __DIR__ . '/myConfigFilePath2'
]);

Scott

@electricjones
Copy link
Owner Author

Ah, I see what you mean. I am talking about individual files and you are talking about directories. I would think that warrants to different methods.

I don't know that I want to deal with recursive searching of files in Manager, its too complicated across systems. I'd rather give the option to use Finder (which we do) and let them deal with it if they want. It's well documented and pretty easy.

So, they would have a couple options to load files:

$manager->loadFiles('some/directory/file.json');
$manager->loadFiles([
  'some/directory/file.json',
  'some/directory/other.json',
  'some/file.php'
]);

$manager->loadFiles($finderInstance); // for all recursive directories, masking and glory

If that is not simple enough, it may be worth thinking about an additional method loadFromDirs() or something?

@smolinari
Copy link
Contributor

My thinking is, as a user, I wouldn't want to have to list out my config files at all. If I add or remove files, then I have to remember to also change the values going into the $manager->loadFiles() method in my code.

Scott

@electricjones
Copy link
Owner Author

Wouldn't that be the perfect option to use Finder?

@smolinari
Copy link
Contributor

Yes. Maybe a list of files would be a feature not really needed?

Scott

@electricjones
Copy link
Owner Author

Closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants