Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120326 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 7668 invoked from network); 17 May 2023 15:31:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 May 2023 15:31:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AFA66180503 for ; Wed, 17 May 2023 08:31:22 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 17 May 2023 08:31:19 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2ad9f2926adso9285951fa.1 for ; Wed, 17 May 2023 08:31:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684337478; x=1686929478; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ClxjLLaaWAxrDRIjuKAU6dfU914OfBzmOLj6HQIGrXY=; b=gylq/qv+xI+CHFrRerRPkRataJlX+Z75FPeRGNxzy//N1ZgD26VQsN9hd02PTp9ZLj O2qK85nca3aizbyYkraFerOhEM0lBvEXsM4jX947RpiDxYGBbMf7PcLy/ODL2s/6IBIh ktSN4IyZl57lhUEtT2gWbmrgGoKDQ06zSOua2WRjnki0Bw3CLiqveXCIKlZqrSswjDuF cNqkzlNSU+qQXRq6QGeIwXeG1K9InXmGBY6HkCU7hVZaedC4rA1tc0mEw8PtY9hptOmZ O6n96BToHV+piF89s7Cmv+DIpMu55XEjZXcWVQmCI9NB+LT6SdYCzIT7KQ3ebf2g2+Hy x7hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684337478; x=1686929478; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ClxjLLaaWAxrDRIjuKAU6dfU914OfBzmOLj6HQIGrXY=; b=QpWkpiWNJsU3p5YS17UGGgsajIoodLglqAwJ+Pn0hHH/UKHHxU6FYZinVGIIERaZyc 4tw5vd1idv1WKzbqbU0HY4UpSYFXFnJcqcvw8M9rPkYm+LW7Hoim0dfw0i98pciXc4RS nSvE1bJhzWXk/qbtSThxrFvug2ssY0f/L2oYelWw+O/KoA2laXJF+EC11AOqZtbtDD8Z ZkMlj69KgVL5lor4JWuS/xtTCGsi/6Iyhyv0xIYUNnIJzcFN2Q9x9xuHmDXqydcAJqPV kmXFm48SZepjXtJij8jkQNVbZ5qakvrMgF675BfvWTJiDarr+kCe95+dH3QMGOqfWc6u cXBA== X-Gm-Message-State: AC+VfDwFosE+WKnbLp2gkTKL/ZuTjqNcZDYjCgr7y/peHsosTEN3A8m3 XEioVy0onVUEUQ2ExsjA7UMVZ2AzNG1nnTPqaXk= X-Google-Smtp-Source: ACHHUZ4Ld6FIPnpiitN7Tr6vi3zeJ0qNDW2pMbe4kHxtIavg10yAGcWB+NH0UB7q56mLuJ944HpDOYpLOHTRHx2VB94= X-Received: by 2002:a2e:9590:0:b0:2a8:a859:b5c7 with SMTP id w16-20020a2e9590000000b002a8a859b5c7mr9241141ljh.0.1684337477173; Wed, 17 May 2023 08:31:17 -0700 (PDT) MIME-Version: 1.0 References: <4ECF6970-2A01-4C47-9B41-87D534F54CB8@shyim.de> In-Reply-To: Date: Wed, 17 May 2023 11:31:05 -0400 Message-ID: To: Timo Tijhof Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000000244f305fbe56197" Subject: Re: [PHP-DEV] [RFC] path_join function From: chasepeeler@gmail.com (Chase Peeler) --0000000000000244f305fbe56197 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 17, 2023 at 11:13=E2=80=AFAM Timo Tijhof wrote: > 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=E2=80=AFPM 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 thi= s > > requires a RFC. So I am here now :) > > > > The idea is to provide in PHP itself a function to join filesystem path= s > > (idea: path_join) like in other languages, node as example ( > > https://nodejs.org/api/path.html#pathjoinpaths). For me this function i= s > > 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 =E2=80=9Ckar= ma points=E2=80=9D > > to create a RFC in the wiki :) > > > > Thanks, > > Soner > Definitely a useful feature, but not sure it needs to be a core function. It's very easy to implement in userland. Userland implementation also allows people to better customize it to their needs. Never going to be using it on windows? Just use /. Only going to be using it on windows? Just use \. Need to support URLs as well as windows directories, create a method that allows specifying the separator. Just for the simple case of windows vs *nix directories, how is it determined which separator to use? If it's the operating system that the code is running on, then what about if I need to generate a *nix style path even though I'm running on Windows, or vice versa? My feeling is that for the function to be easy to use, you have to cut out too many scenarios which causes users to have to fallback to their own implementations anyway. Finally, there aren't going to be any meaningful performance gains which would possibly justify not implementing it in userland. --=20 Chase Peeler chasepeeler@gmail.com --0000000000000244f305fbe56197--