Re: [RFC] [Discussion] Add WHATWG compliant URL parsing API

From: Date: Fri, 19 Jul 2024 22:55:27 +0000
Subject: Re: [RFC] [Discussion] Add WHATWG compliant URL parsing API
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Mon, Jul 8, 2024 at 11:24 AM Lanre <[email protected]> wrote:

>
> On Fri, Jun 28, 2024 at 3:38 PM Máté Kocsis <[email protected]>
> wrote:
>
>> Hi Everyone,
>>
>> I've been working on a new RFC for a while now, and time has come to
>> present it to a wider audience.
>>
>> Last year, I learnt that PHP doesn't have built-in support for parsing
>> URLs according to any well established standards (RFC 1738 or the WHATWG
>> URL living standard), since the parse_url() function is optimized for
>> performance instead of correctness.
>>
>> In order to improve compatibility with external tools consuming URLs
>> (like browsers), my new RFC would add a WHATWG compliant URL parser
>> functionality to the standard library. The API itself is not final by any
>> means, the RFC only represents how I imagined it first.
>>
>> You can find the RFC at the following link:
>> https://wiki.php.net/rfc/url_parsing_api
>>
>> Regards,
>> Máté
>>
>>
> I was exploring wrapping ada_url for PHP (
> https://github.com/lnear-dev/ada-url). It
> works, but it's a bit slower,
> likely due to the implementation of the objects. I was planning to embed
> the zvals directly in the object, similar to PhpToken, but I haven't had
> the chance and don't really need it anymore. Shouldn't be too much work to
> clean it up though
>

I’ve updated the implementation, and with Ada 2.9.0, the performance is now
closer to parse_url for short URLs and even outperforms it for longer
URLs. You can see the benchmarks in the "Run benchmark script" section of
[this GitHub Actions run](
https://github.com/lnear-dev/ada-url/actions/runs/9982725628/job/27589011554
).

cheers,
Lanre


Thread (152 messages)

« previous php.internals (#124507) next »