Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123956 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 7700D1ADF7C for ; Thu, 27 Jun 2024 19:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719516302; bh=qMSDxeFyXlmOcQFlcTQX9Ngykrab4+rKdTyxS6Gb0GM=; h=References:In-Reply-To:From:Date:Subject:To:From; b=VHKB4i854FCAyPgLd+NqMH+xBVCjWNLaxp1Ef3TQlX1v2DsUppMbQgUUs7PGqaK8U BhkTNLKYAas7WlLv3xhXEZbVPVbTLQC2zV55+NDVJjaby7aAp9tU9yhA147MSJ03bd z1IaMZULcq0df6PG1GTTSqJQMY6dnxZ/faI1PYi0zL2g1yZkqcP9bJabA9tWwPzSXV z7jCxlhnwY1cPyBL1H8y659mN269sVFJ2e/xZRuSDm/EVLZLH+ziTA7xHycCQ6vMSP Lys9S1xWe0jAuNLS7aNKlp7KotiL0Ssr/qKAoNaTRF0X+PzEB5I+M4FfQIIGvezcUz t/WC2/Dye6hsQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5093818057A for ; Thu, 27 Jun 2024 19:24:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 27 Jun 2024 19:24:57 +0000 (UTC) Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a724cd0e9c2so625648766b.3 for ; Thu, 27 Jun 2024 12:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719516217; x=1720121017; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=LkIf+Q8oAGf0mnMPbzjIJlkbTklNkUUL/6I+oC0iS68=; b=Eb6SlNzTqcf7aXKZwEetfapX1Sh095uImFT4BiLosv/KMVacAQ7dd//YtzvqeUeSRW PJbY0bCwRh/y1K7QmmkcUrL1fWQQH26/Pq3J91XL9g730UWhxD2bWpphDpigyz9qCAD9 2lp52XUtJpvRKw/0z5iW8djXlENfNbREEcPPWnN8duuPIBLI6/anI3MqXTD29++6AUdy If+s5Sa/e2Yrwa0d8rJWf56mPOKFWbyjhnnqvX6PrYUItxytFdjElhkFbagcigqCt9lQ Y+omzSz/wF21ZrjnrdFuzsp9QCqAPYnvHr5TTj5qeOhxknb8csC26VcjI7h4LMWjExyY Sd8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719516217; x=1720121017; h=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=LkIf+Q8oAGf0mnMPbzjIJlkbTklNkUUL/6I+oC0iS68=; b=h2RHyRzNxm7sLbWF7co0/53Bv1yRz+x5loe0Nt8qVoonVczYgLYwDh1g/1A4aEm+BR HVncnAb4CR9ATXO+szejHJOXU+zkPZBPNhom+q3zKr5cqR7p7n4cpsaFRigrpp25ckg4 f87mi04OzMrN5RskcwFAAl+HV5ude8/hQCzrhK/UnUe2rp/gu3osVnUzOEv985IBhXIE oe2/VG8fLk+gagmuYcij1KS8lTedHTdJexQtNi0ohsT2DsdZkJUmN+l4GwkORnTBB2Q2 p0hDaQynH9f/JamKUd5ZeGJB4+UzBWb9rmvRZZiZF5Q4mxRXfNeMoMrc6utIrsg92XaS zviA== X-Gm-Message-State: AOJu0YzpS9HzjSYplugAU3EY5ra/kXUHNll3YgUuRhOAQFNvH0kDKWl2 5hzMq2I6l4i37eKKDyzdy+j+x3rFBRTn4RV2Y7m+DnzNFCc1jyiKpov4JG13JZR0RxZZXxiZQI9 JSyIAM+p3YRBgwkKjJAJAQBuTlGk0PQ== X-Google-Smtp-Source: AGHT+IG889QdmVrNDAKVifzGwjkM3turgrh09DRV7bxegui1XgdXn2z+7y1aavgItqfxP12vr5xdk/oW81x4S7paMd0= X-Received: by 2002:a17:906:e48:b0:a6f:618b:4d7c with SMTP id a640c23a62f3a-a7245c824b8mr872209466b.51.1719516217028; Thu, 27 Jun 2024 12:23:37 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 27 Jun 2024 15:23:24 -0400 Message-ID: Subject: Fwd: [PHP-DEV] [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript To: PHP internals Content-Type: multipart/alternative; boundary="0000000000004d39d2061be411c7" From: tendoaki@gmail.com (Michael Morris) --0000000000004d39d2061be411c7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jun 27, 2024 at 1:02=E2=80=AFPM MKS Archive wrote: > > Interesting to see this. Serendipitous given the email I sent on the list > in reply to Larry. > > My initial thoughts: > > 1. I really like the concept of cleaning up issues that BC make impossibl= e > to fix by introducing modules. > Thanks. The sticking point is what degree of change should be occurring. PHP isn't as behind an 8-ball as JavaScript is since the dev can choose their PHP version and hence deprecation works most of the time for getting rid of old stuff. But not always. Changes that are incompatible with what came before need a way to do things the old way during transition. Again, see PHP 6 and unicode, which snowballed until it was clear that even if PHP 6 had been completed it wouldn't be able to run most PHP 5 code. > 2. No need for autoloaders with modules; I assume this would be obvious, > right? > > Depends largely on whether modules can include and require to get access to old code. I also didn't discuss how they behave - do they share their variables with includes and requires? > 3. Not a good idea to use an ini setting; most view them to be problemati= c. > 4. .htaccess =C3=AEs Apache-only, so a non-starter anyway. > 5. The first script should not be a module. If you want that, have a 1 > line index.php file do an import. > I love this idea. > 6. Modules should be directories, not .php files. Having each file be a > module makes code org really hard. > Yes, but that is how JavaScript currently handles things. It is currently necessary when making large packages to have an index.js that exports out the public members of the module. This entry point is configurable through the package.json of the module. > 7. Modules would have a symbol table metadata file generated by IDEs and > during deployment. > Node.js uses package.json and the attendant npm to do this sort of prep work. And it's a critical part of this since modules can be versioned, and different modules may need to run different specific versions of other modules. > 8. If no metadata file in directory PHP can generate one in memory during > first directory access. > 9. .php files in modules as identified by metadata file should not be > loadable via HTTP(S). > Those are implementation details a little further down the road than we're ready for, I think. > 10. Having exports separate from functions and classes seems like it woul= d > be problematic. > Again, this is how they work in JavaScript. Not saying that's the best approach, but even if problematic it's a solved problem. > 11. Exports could be implemented as attributes, which could be really > elegant. > 12. Exports as attributes pairs with the symbol on the line above, and > would enable easy aliasing. > Ultimately everything in JavaScript is an object. JavaScript provides a mechanism for handling a module file with a single default export, but it supports multiple exports from the same file which arrive as an object best approximated in PHP as a static class. I could hash out further, but again, I'd like to gauge some interest and very high level feedback. I'm also interested in learning on how other module systems out there do work. I'm picking of JavaScript because most of the PHP community has to use it as well for client side scripting and so most of us should have at least passing familiarity with it. > 13. And finally, when are you starting the RFC? :-) > It's too early for anyone to start at this moment - and while I certainly am willing to help I'm not qualified to take the lead on this. If adopted, this is a massive change, and the results of this conversation won't hit for years. Let's take our time. For one, this overarching project will need multiple coordinated RFC's, as well as figuring out what to do and also in what order. --0000000000004d39d2061be411c7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Thu, Jun 27, 2024 at 1:02=E2=80=AFPM MKS Archive <mikeschinkel@gmail.com> = wrote:

Interesti= ng to see this. Serendipitous given the email I sent on the list in reply t= o Larry.

My initial thoughts:

=
1. I really like the concept of cleaning up issues that BC make imposs= ible to fix by introducing modules.

=
Thanks. The sticking point is what degree of change should be occurrin= g. PHP isn't as behind an 8-ball as JavaScript is since the dev can cho= ose their PHP version and hence deprecation works most of the time for gett= ing rid of old stuff. But not always. Changes that are incompatible with wh= at came before need a way to do things the old way during transition. Again= , see PHP 6 and unicode, which snowballed until it was clear that even if P= HP 6 had been completed it wouldn't be able to run most PHP 5 code.
=C2=A0
<= div>2. No need for autoloaders with modules; I assume this would be obvious= , right?


Depends= largely on whether modules can include and require to get access to old co= de. I also didn't discuss how they behave - do they share their variabl= es with includes and requires?
=C2=A0
3. Not a good idea to use = an ini setting; most view them to be problematic.
4. .htaccess = =C3=AEs Apache-only, so a non-starter anyway.
5. The first script= should not be a module. If you want that, have a 1 line index.php file do = an import.

I love this idea.=C2= =A0

=C2=A0
6. Modules should be directories, not = .php files. Having each file be a module makes code org really hard.
<= /div>

Yes, but that is how JavaScript curre= ntly handles things. It is currently necessary when making large packages t= o have an index.js that exports out the public members of the module. This = entry point is configurable through the package.json of the module.
=C2=A0
= 7. Modules would have a symbol table metadata file generated by IDEs and du= ring deployment.

Node.js uses p= ackage.json and the attendant npm to do this sort of prep work.=C2=A0 And i= t's a critical part of this since modules can be versioned, and differe= nt modules may need to run different specific versions of other modules.
=C2=A0
=
8. If no=C2=A0metadata file in directory PHP can generate one in memor= y during first directory access.=C2=A0
9. .php files in modules a= s identified by metadata file should not be loadable via HTTP(S).=C2=A0

Those are implementation details a= little further down the road than we're ready for, I think.=C2=A0

=C2=A0
10. Having exports separate from functions and= classes seems like it would be problematic.
<= br>
Again, this is how they work in JavaScript. Not saying that&#= 39;s the best approach, but even if problematic it's a solved problem.<= /div>
=C2=A0
11. Exports could be implemented as attributes, which could be reall= y elegant.
12. Exports as attributes pairs with the symbol on the= line above, and would enable easy aliasing.
<= br>
Ultimately everything in JavaScript is an object. JavaScript = provides a mechanism for handling a module file with a single default expor= t, but it supports multiple exports from the same file which arrive as an o= bject best approximated in PHP as a static class. I could hash out further,= but again, I'd like to gauge some interest and very high level feedbac= k. I'm also interested in learning on how other module systems out ther= e do work. I'm picking of JavaScript because most of the PHP community = has to use it as well for client side scripting and so most of us should ha= ve at least passing familiarity with it.
=C2=A0
13. And finally,= when are you starting the RFC? =C2=A0:-)

=
It's too early for anyone to start at this moment - and whil= e I certainly am willing to help I'm not qualified to take the lead on = this.
=C2=A0
If adopted, this is a massive change, and = the results of this conversation won't hit for years. Let's take ou= r time. For one, this overarching project will need multiple coordinated RF= C's, as well as figuring out what to do and also in what order.
--0000000000004d39d2061be411c7--