Re: [RFC] path_join function

From: Date: Wed, 17 May 2023 15:13:08 +0000
Subject: Re: [RFC] path_join function
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-120325@lists.php.net to get a copy of this message
In case it is of interest, the implementation we use on Wikipedia as part of MediaWiki, is available on Packagist: https://packagist.org/packages/wikimedia/relpath https://www.mediawiki.org/wiki/RelPath -- Timo Tijhof, Wikimedia Foundation. https://timotijhof.net/ On Wed, May 17, 2023 at 3:54 PM <php@shyim.de> wrote: > 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 (#120325) next »