Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127313 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 lists.php.net (Postfix) with ESMTPS id 06E921A00BC for ; Wed, 7 May 2025 20:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1746650979; bh=KRqK1XvJ10e9YuZUtGAd3uoc6aThPOnIwJZ/nI57Xfw=; h=References:In-Reply-To:From:Date:Subject:To:From; b=Q4Mm+zdkU+xyTWwEaMeSTaM5c16mrjdRBE2lmv26bIHb3u3RY/9Kadvsta/ncEFU5 brvkwGWCrFNqCdHGZL+RWdIzhK44SpYp7PeZAJU6eEmh4m+JkVUdcNiu8hnremZ3He 6LuI00ytEe7iJL/QeSQMzDRpx1PLdn+yq3VZMiSROLFnNBT99dLFB7G0TyjLjT99fi +PmGkX3gLohJtQGfu1pch9NdDv939yQ2EgfPhhkoCn+eoQ4NADRBz+XptSb+/A+HC7 39ZA4fTlXb+dZT/pTijurO/Qo0hfjYC2MruudwJfi39N/1290BUs4xve1a5YyKutBn aweVkIeOEmd2g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5BF5218006A for ; Wed, 7 May 2025 20:49:37 +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_H2,SPF_HELO_NONE, SPF_PASS 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-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (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 ; Wed, 7 May 2025 20:49:27 +0000 (UTC) Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-47677b77725so2682471cf.3 for ; Wed, 07 May 2025 13:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746651100; x=1747255900; 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=KQkc3ZOCWavWRjXLd3lQa5dWkfbshRqVh7w+dFrhOoU=; b=GfKICd5w63lHjFMLZ+KUyA9aeX+7iKLWKvW84AET6+g2AsP28Zps08OYzeQud6M1FK /DlT0X7mB9EYuJySLwtUKnXk/vbkkgZkDpojk9Lgjg+6xIPURLl6NnBRDToefQdY+m3e PAy+xKntCnA66Z29QgDqO63SxZJAUjeV59KQ7k1Z2zFdZvr3dHmKerJ22F6OHch4LCks AIh3d9nWCypM6A6h0rTLpz+RsW15kF+lqNAyYyCYRMjPZoBQzpGxJTraF1ucMoiV6PFM op9oZ0e/epNoT8nZeYuHQ1/RkGLFrVXGEdmFAd+DWyua+zdeKOZ2u/IS9vGkdXHLzrB9 1RBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746651100; x=1747255900; 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=KQkc3ZOCWavWRjXLd3lQa5dWkfbshRqVh7w+dFrhOoU=; b=IyZebD5SgaPQe7KWRpkD3ghz4MiN3AjHQyklBKdg7xBPYovUx5uqySBdn/ZcbOyk5K wFkdNTn/btZX1S9JkYKnLt2Odh4IhUSKW99Dh6hJZn2R0tvozhyx7QD1JpyCDl/qCF8d qsq98wYd9jHl0Si+TJVZ1uGUA/S1zIotrbQq6gfOMQm/MfxPjVLcfT7Ve/CE88NGMOBD 1OgduFVum7QnFve8avfm99NkH5waaZ+bR4yJFh1r0SrjVA6NOngXI/0QbUAduhcBgAZC fiJx5u7scOxG2RLUkm3V2EqxtmbS4F/IUUnOA6KZr6aQxNVbarzKqbnGABrNIIyRApLN GvLA== X-Gm-Message-State: AOJu0YxFbINMfQhAmtbDAplihCfDV+MnCbRB5VmgroibO8b1wKphLm8y g111igpk6y44UDGYZupEQIbB356VAXGJYNBVgQQEMuEIO26d6RUHRGJoejMvk+HrUkrbaOHf+Re +PDl73MaMhTNPxgzIipbnn12zAzshXw== X-Gm-Gg: ASbGnctHPDruh9iiI041BdVd0FJBDzZy/Pm4PytQw4fA9M8apwCz78YP9dB9SPFX96H VPVu5O5uZ1pHlu0Dl+Gh/a+hbiZJP39fMCQ453tydzDSc4MBISM7iqut45Iq76wvcSnIKt7n3uj Lce0nIqZydo6ztg5X9jbDpVwVY3ws3Z/6xXkcYOaNquFIDFr4a7mI4 X-Google-Smtp-Source: AGHT+IErzOQOwZWYY2EVYQZA0ueEKZK+rJcuSfOvq0JbQXX+jAmoCzVsADyhf/WStZAEaJXm2IjclzQRtJTo9CNRXdY= X-Received: by 2002:a05:6214:301c:b0:6e8:9086:261 with SMTP id 6a1803df08f44-6f54c370f58mr14372806d6.3.1746651099832; Wed, 07 May 2025 13:51:39 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <6d2adbbb-f4fa-41e6-9ec1-179685ded039@rwec.co.uk> In-Reply-To: <6d2adbbb-f4fa-41e6-9ec1-179685ded039@rwec.co.uk> Date: Wed, 7 May 2025 16:51:29 -0400 X-Gm-Features: ATxdqUGlxXSG3ZgxveTtI11vgZbKhWVPlFNsZI_pGPjEmbI3CM_pfOXCyEu6BgQ Message-ID: Subject: Re: [PHP-DEV] Modules, again. To: PHP internals Content-Type: multipart/alternative; boundary="0000000000005a26f9063491e60b" From: tendoaki@gmail.com (Michael Morris) --0000000000005a26f9063491e60b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 7, 2025 at 3:24=E2=80=AFPM Rowan Tommins [IMSoP] wrote: > > Problem number 2 is what you seem to be trying to address. > The main thing, yes. This solution incidentally solves class privacy issues several unrelated and failed RFC's have addressed, including Nested Classes which is currently not doing so well in its vote. > > NPM is notorious for creating a giant directory of tiny modules, because > that's what the language design encourages. > > Indeed. Definitely the bathwater to be thrown out. > > That's not how PHP works, and it never will be. In PHP (and other > languages like Java, and C#), declarations have a single fully-qualified > name. If you want two different versions of the same library, you will > need to find a way to make their declarations use different > fully-qualified names. > Other libraries have the means to import into a namespace because their namespaces aren't just a quick and dirty string replacement. I've even proposed such a long, long time ago - allowing namespace to be the second argument of require, only to have that shot down as "require isn't a function." or some such. > The main exception, as you have pointed out, is plugin architectures > like WordPress, where the plugin might want to "privately" use some > library without impacting the host application and other plugins. It's not just WordPress. Drupal and other CMS's have extensions, but their reliance on composer means abandoned plugins that need an old library can block updating the whole system. The larger and more popular the application is the more likely this becomes. And like it or not WordPress haters on the board, for as much as WordPress sucks (and I will agree, it sucks hard) it still have a 50% - 80% market share of PHP websites depending on who you ask. A lot of this stems from the fact that end users just want their site to work - they don't give a rat's ass about dependencies and the like - and needing to drop a plugin to upgrade a site will put a bad taste in their mouth at best. > For > those, userland solutions already exist - a random search turned up this > one, which lists some alternatives: > https://github.com/BrianHenryIE/strauss?tab=3Dreadme-ov-file#alternatives > > I've seen Strauss in action. It's called monkey-typing. Other languages support this sort of monkey typing to some degree - PHP can only do it by doing an expensive and error prone programmatic keyword search of the source files and transforming them. The end result has to be shipped with the module, severing its dependencies from getting security updates. I *do* think PHP would benefit from some native concept of "module" for > other reasons, e.g. marking internal components, optimising across > multiple files. I *do not* think that ES/JS/TS is a suitable model to > look at, because it is starting from a fundamentally different concept > of what a declaration is. > So what do you suggest then? Go's model? Rusts? Gradle or Maven from Java? Shooting down stuff is trivial, finding solutions is the real work. > > --0000000000005a26f9063491e60b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Wed, May 7, = 2025 at 3:24=E2=80=AFPM Rowan Tommins [IMSoP] <imsop.php@rwec.co.uk> wrote:

Problem number 2 is what you seem to be trying to address.
=

The main thing, yes. This solution incidentally solves = class privacy issues several unrelated and failed RFC's have addressed,= including Nested Classes which is currently not doing so well in its vote.=
=C2=A0
NPM is notorious for creating a giant directory of tiny modules, because that's what the language design encourages.


Indeed. Definitely the bathwater to be= thrown out.
=C2=A0

That's not how PHP works, and it never will be. In PHP (and other
languages like Java, and C#), declarations have a single fully-qualified name. If you want two different versions of the same library, you will
need to find a way to make their declarations use different
fully-qualified names.

Other libraries = have the means to import into a namespace because their namespaces aren'= ;t just a quick and dirty string replacement.=C2=A0 I've even proposed = such a long, long time ago - allowing namespace to be the second argument o= f require, only to have that shot down as "require isn't a functio= n." or some such.

=C2=A0
The main exception, as you have pointed out, is plugin architectures
like WordPress, where the plugin might want to "privately" use so= me
library without impacting the host application and other plugins.

It's not just WordPress.=C2=A0 Drupal and other= CMS's have extensions, but their reliance on composer means abandoned = plugins that need an old library can block updating the whole system. The l= arger and more popular the application is the more likely this becomes.=C2= =A0 And like it or not WordPress haters on the board, for as much as WordPr= ess sucks (and I will agree, it sucks hard) it still have a 50% - 80% marke= t share of PHP websites depending on who you ask.=C2=A0 A lot of this stems= from the fact that end users just want their site to work - they don't= give a rat's ass about dependencies and the like - and needing to drop= a plugin to upgrade a site will put a bad taste in their mouth at best.

=C2=A0
For
those, userland solutions already exist - a random search turned up this one, which lists some alternatives:
https://github.com/BrianHen= ryIE/strauss?tab=3Dreadme-ov-file#alternatives


I've seen Strauss in action. It= 9;s called monkey-typing.=C2=A0 Other languages support this sort of monkey= typing to some degree - PHP can only do it by doing an expensive and error= prone programmatic keyword search of the source files and transforming the= m. The end result has to be shipped with the module, severing its dependenc= ies from getting security updates.

I *do* think PHP would benefit from some native concept of "module&quo= t; for
other reasons, e.g. marking internal components, optimising across
multiple files. I *do not* think that ES/JS/TS is a suitable model to
look at, because it is starting from a fundamentally different concept
of what a declaration is.

So what do yo= u suggest then?=C2=A0 Go's model?=C2=A0 Rusts? Gradle or Maven from Jav= a? Shooting down stuff is trivial, finding solutions is the real work.

--0000000000005a26f9063491e60b--