[RFC] path_join function

From: Date: Wed, 17 May 2023 14:54:25 +0000
Subject: [RFC] path_join function
Groups: php.internals 
Request: Send a blank email to internals+get-120323@lists.php.net to get a copy of this message
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

« previous php.internals (#120323) next »