Skip to content

Instantly share code, notes, and snippets.

@ahuggins
Last active April 17, 2017 18:32
Show Gist options
  • Select an option

  • Save ahuggins/21d1af3c1e274cfa305d8220fb5303f2 to your computer and use it in GitHub Desktop.

Select an option

Save ahuggins/21d1af3c1e274cfa305d8220fb5303f2 to your computer and use it in GitHub Desktop.
Illuminate\Filesystem question
<?php
//...
dd(collect($this->fs->files('archive/'.$this->date)));
//returns
Illuminate\Support\Collection {#79
#items: array:24 [
0 => "archive/2017-03-23/Something_2017-03-23_03-53-21.tsv"
1 => "archive/2017-03-23/SomethingElse_2017-03-23_03-46-36.tsv"
2 => "archive/2017-03-23/AnotherFile_2017-03-23_03-52-55.tsv"
3 => "archive/2017-03-23/AnotherFileCompletely_2017-03-23_03-52-30.tsv"
dd(collect($this->fs->allFiles('archive/'.$this->date)));
//returns
Illuminate\Support\Collection {#79
#items: array:72 [
0 => Symfony\Component\Finder\SplFileInfo {#90
-relativePath: ""
-relativePathname: "Something_2017-03-23_03-46-36.tsv"
// truncated
}
1 => Symfony\Component\Finder\SplFileInfo {#89
-relativePath: ""
-relativePathname: "SomethingElse_2017-03-23_03-53-21.tsv"
// truncated
}
2 => Symfony\Component\Finder\SplFileInfo {#91
-relativePath: ""
-relativePathname: "AnotherFile_2017-03-23_03-52-55.tsv"
// truncated
}
3 => Symfony\Component\Finder\SplFileInfo {#92
-relativePath: ""
-relativePathname: "AnotherFileCompletely_2017-03-23_03-52-30.tsv"
// truncated
}
Should files and allFiles return similar arrays of SplFileInfo Objects, or both return arrays of string paths?
Seems like it would be convenient to switch between files/allFiles and not have to adjust how you handle that value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment