Re: Filesystem path APIs
| From: | Erick de Azevedo Lima | Date: | Sun, 10 Dec 2023 17:24:56 +0000 |
| Subject: | Re: Filesystem path APIs | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-121980@lists.php.net to get a copy of this message | ||
I'm in favor for this. I think that, since you already have a built-in file
API, adding useful functions is always good. I use *\str_starts_with* and
*\str_ends_with* a lot in my code. In Laravel, which is the most used
Framework these days, you have the \Illuminate\Supports\Str::startsWith and
\Illuminate\Supports\Str::endsWith, but it did stop the implementation of
those functions in the core and I'm glad for it.
Best regards,
Erick
Em sáb., 9 de dez. de 2023 às 13:21, Niels Dossche <dossche.niels@gmail.com>
escreveu:
> On 12/9/23 10:40, David CARLIER wrote:
> > On Fri, 8 Dec 2023 at 16:10, Niels Dossche <dossche.niels@gmail.com>
> wrote:
> >
> >> Hi David
> >>
> >> On 08/12/2023 10:08, David CARLIER wrote:
> >>> I think these would be great additions to PHP as working with paths
> >> and files is a core part of any programming language.
> >>>
> >>>
> >>> Seems like it, is there an argument to be made to, let's say, in the
> >> performance side ?
> >>
> >> A native implementation is going to be faster than an implementation in
> >> userspace.
> >> However, I don't think that matters because the performance is likely
> >> dominated by the I/O you do after constructing a path.
> >> You'd need to construct a large number of paths before you notice
> anything
> >> I guess.
> >>
> >> Cheers
> >> Niels
> >>
> >
> > Very true, so what would be the argument beside having those as
> "builtins"
> > as opposed to external components ?
> >
>
> Mainly for convenience reasons and a correct implementation provided by
> PHP.
> Many functions in PHP are not strictly necessary because they can be
> implemented in userland.
> They're only there for convenience reasons. Where to draw the line is
> difficult.
> To me they complement the realpath(), dirname(), basename() functions.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>