Closed
Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
RFC? | yes |
Symfony version | latest |
When working with filesystem it's always very cumbersome to create path from different segments. For example, create full path from base directory, subdirectory and filename. Especially if you need to compare paths later.
What I propose is to add $filesystem->join()
method. It's purpose would be to merge different path segment with path separator in a predictable way.
$filesystem->join(['some', 'path', 'segment']); // 'some/path/segment'
$filesystem->join(['/some/path/', '/subdir/', 'filename.tmp']); // '/some/path/subdir/filename.tmp'
// notice how it behaves better than implode('/', $array) in regards to doubleslashes
// following OS depended behavior is up to discussion
$filesystem->join(['c:\', '/subdir/', 'filename.tmp']); // 'c:/subdir/filename.tmp'
// that this way one can be sure that slash is separator and it works fine due to PHP transforming it on the fly when accessing the file
// also this could be useful
$filesystem->toOsSpecific('some/path\to\some/folder');
// 'some\path\to\some\folder' on windows
// 'some/path/to/some/folder' on linux
$filesystem->toPathWithSlashes('some\path/to\some\folder');
// always 'some/path/to/some/folder'
What do you think? I'd be happy to send a PR after it's disussed.
Metadata
Metadata
Assignees
Labels
RFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)