Hey,

I have created on GitHub a feature request for a path_join function 
(https://github.com/php/php-src/issues/11258) and got the label that this 
requires a RFC. So I am here now :)

The idea is to provide in PHP itself a function to join filesystem paths (idea: 
path_join) like in other languages, node as example 
(https://nodejs.org/api/path.html#pathjoinpaths). For me this function is some 
kind of base filesystem functionality like basename, realpath.

Example usage:

path_join('/base', 'my', 'path'); // /base/my/path
path_join('/base', 'my', 'path', 'test', '..'); // /base/my/path

Why not just string concatenation?

When you concat just the paths you have to think about:
- normalize string part to strip ending slash
- for windows compatibility you have to use DIRECTORY_SEPERATOR

I think this can improve the developer experience when working with filesystems 
a lot and people can delete their implementation.

I am really looking for your feedback, right now I have no “karma points” to 
create a RFC in the wiki :)

Thanks,
Soner

Reply via email to