Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127441 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 06F8C1A00BC for ; Sat, 24 May 2025 13:12:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748092214; bh=mAeGwvp2ba7NExeiKOxqyBPZH5C2leI0U8WacG2ArIU=; h=Date:From:To:In-Reply-To:References:Subject:From; b=TDjU+a770nCTxo/sUFEBT8hCAm7AtSJThNfvMtkUaHl3y3l9hzgR5Ltbe1dhIjkc1 +KoU0EwixqxPs08bZDfE1zzENfus5PPaS2JxlhtBLGRyvxyEOAkM54jgEmKs4645FW TP1xSXyh2QMl6BG1LpauS2dnJS3awN23YabzUh6h4srglAslwWvTC+33avuZK85gho n5+bqtqhfvK55fMZXkmqqLoQJWCbxjyzMu2fNlLrSHBOcRqC7zaanuHX9TZ8dD+NuI 9Ykd+j8GAWbPOUF2ks5BUQdGMkrqnGAZGJRpdFJ9IzaOgU8En/h4N+Aypq0GL+xgVP WsJbXQPxi7OgA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E922E180061 for ; Sat, 24 May 2025 13:10:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-b7-smtp.messagingengine.com (fhigh-b7-smtp.messagingengine.com [202.12.124.158]) (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 ; Sat, 24 May 2025 13:10:12 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id A51C125400B4 for ; Sat, 24 May 2025 09:12:19 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-05.internal (MEProxy); Sat, 24 May 2025 09:12:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1748092339; x=1748178739; bh=mAeGwvp2ba 7NExeiKOxqyBPZH5C2leI0U8WacG2ArIU=; b=JR+Dttd6Y+uA1decmxr+joJj3S 8PdVGwqwa9Td6nBrhMNFzefldtApOpCA8onRN40T3HAd79Z10wAWHRF3ZSlZn5sc VO2clOZvio2feOoL1zn0XZQSHNv+lNzwfkk35ByvzCg4ETrpLQDIi6md5EnlQVIb YgQtC9NwCatrouldPG2eooWmjTCV1l2B4z8nuuwdv4xFqanFelS6C2I2PVCPw5Ro H2s9eGTl74FWutzNpv/2gTkhMUQC6bZ+T897flj7BXZEPY8K3U2Dg+HjyXJ1C4zQ 1Ia34H6/m9vgW7zRGMg302Lz7onlb7XqacErg1SnYVpHjn3khdQi1j82Q7FQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1748092339; x=1748178739; bh=mAeGwvp2ba7NExeiKOxqyBPZH5C2leI0U8W acG2ArIU=; b=NeDiEUJt8qYZxn3d4KdnXZh/gk02BO2B91PUTO+FxNRxH9rB+X8 bkqVWC639TzdysCTso8UNBzVQK/CvGmW1s8M+T7OxV0ydhxCJuRbR9fSAh/uuGPt CmNMOt97daa30Dt6t1+smfXdCJRv2WJtAd2Jnihjt4JRYGP0V1HreIIML+LYn9TH IqDZ2MKHvp7fQr1+jyjtas7g6F7oVhWH4bAPYVGgAHTz0g8u/3OLl7YZ2UQEtN3F Ad+0S5MxmaQyO4AJu6LQIrlxRCob8W8J+HxP7OcU87NkueaetoyO9bxGzYrANj/d Tsz2mYsJC70Ujh2Ly7dNQWvANYFR9vpDfog== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddtgdduudekudculddtuddrgeefvddrtd dtmdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggft fghnshhusghstghrihgsvgdpuffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftd dtnecunecujfgurhepofggfffhvffkjghfufgtsegrtderreertdejnecuhfhrohhmpedf tfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecugg ftrfgrthhtvghrnheptdeujedttefhueelhfdtleeiudetlefftdduleehffegtdeihefh leeijefgveegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheprhhosgessghothhtlhgvugdrtghouggvshdpnhgspghrtghpthhtohepuddpmhho uggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrph hhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 1B7F23020061; Sat, 24 May 2025 09:12:19 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T018bd9ffc60205f7 Date: Sat, 24 May 2025 15:11:57 +0200 To: internals@lists.php.net Message-ID: <2adbff61-5e11-4d39-ab5c-d7950a4550a6@app.fastmail.com> In-Reply-To: <10D95B6E-094B-4EAE-A18A-AF6B795CB352@rwec.co.uk> References: <3ae9a6ea-f135-472b-b2bf-e6cd6ebad299@app.fastmail.com> <9A26F72B-D0EF-414F-B193-BED3CAB26A0B@rwec.co.uk> <9f6a0d6e-27c3-4f77-aed6-e55147442b6f@app.fastmail.com> <673fd2db-b07f-439b-a4f2-e9519108d159@app.fastmail.com> <78641D8B-AF1D-4912-920A-D75A37C32F05@rwec.co.uk> <354cb888-97c4-4f8c-a0da-359d1e63c0f9@rwec.co.uk> <10D95B6E-094B-4EAE-A18A-AF6B795CB352@rwec.co.uk> Subject: Re: [PHP-DEV] Module or Class Visibility, Season 2 Content-Type: multipart/alternative; boundary=c6d792634d33400a9a2cfb128927d161 From: rob@bottled.codes ("Rob Landers") --c6d792634d33400a9a2cfb128927d161 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, May 24, 2025, at 11:34, Rowan Tommins [IMSoP] wrote: >=20 >=20 > Hi Michael, >=20 > I'm going to skip over all the details about the autoloader for now, b= ecause I think they're going deep into implementation details, and I wan= t to focus on the same top-level design as my previous email. >=20 >=20 > On 23 May 2025 02:27:41 BST, Michael Morris wrote: > >Bobs docs needs an older version of Monolog and is configured appropr= iately > >in its composer.json file, so ... v1 is prefixed to the > >namespace declarations in Monolog\Logger and the file is included. The > >engine aliases BobsDocs\Monolog\Logger to \v1\Monolog\Logger. >=20 >=20 > If I'm following correctly, you suggest that we would end up with clas= s names like this: >=20 > \v1\Monolog\Logger > \v2\Monolog\Logger > \v5\Google\Client > \v7\Google\Client >=20 > It feels like there's a lot of complexity in the package manager here = - it's got to keep track of which versions of each package are installed= , what they depend on, and decide what prefixes need to be used where. Y= ou also suggest that one version of each package is left with no prefix,= which adds even more complexity. >=20 >=20 > >The Googl\ApiClient of BobDocs is again, up to the autoloader. Assumi= ng it > >too is different (since it's using an older Monolog) >=20 > The biggest problem comes when this assumption doesn't hold. I actuall= y chose these particular packages to illustrate this problem, then left = it out of my previous message. It happens that the latest version of goo= gle/apiclient supports both monolog/monolog 2.9 and 3.0, so it's possibl= e to have:=20 >=20 > - AlicesCalendar wants to use google/apiclient 2.18 and monolog/monolo= g 2.9 > - BobsDocs wants to use google/apiclient 2.18 and monolog/monolog 3.0 >=20 > If the package manager is adding prefixes to individual package versio= ns, we will have one class called \v2_18\Google\Client containing our fa= miliar "new Logger" line. AlicesCalendar will expect that line to create= a \v2_9\Monolog\Logger, but BobsDocs will expect it to create a \v3_0\M= onolog\Logger. We can't please both of them without creating an extra co= py of Google\Client with a different prefix. >=20 > So the version of an individual package isn't enough to decide the pre= fix, we need to know which *set* of packages it belongs to.=20 >=20 >=20 > My suggestion uses a much simpler rule to define the prefix: if it's l= oaded "inside" AlicesCalendar, add the prefix "\AlicesCalendar\". All th= e classes that are "inside" are completely sandboxed from the classes "o= utside", without needing any interaction with a package manager. >=20 > As far as I know, this is how existing userland solutions work, and I = haven't yet spotted a reason why it needs to be any more complex than th= at. >=20 >=20 > Regards, > Rowan Tommins > [IMSoP] >=20 My only concern is how this would be handled in the class tables. Right = now, \AlicesCalendar\Monolog\Logger and \BobsDocs\Monolog\Logger would b= e considered entirely different types -- as in, not compatible. So if Al= icesCalendar returns a type that BobsDocs expects, they won't be able to= talk to each other. So, this means we'd need a couple of different types of dependencies: 1. "direct dependencies" that work in a containerized way 2. "parent dependencies" that expect a parent to provide the dependency= so it can interoperate between packages I assume that it will be up to a dependency resolver (either composer or= something else) will need to figure out which direct dependencies to "h= oist" up and provide a compatible version between the two packages. That then begs the question of whether this complication is needed at al= l? I can understand why having a 'containerized' package system is usefu= l (in the case of WordPress or plugins in general), but I'm wondering if= it is actually needed? If we look at npm and yarn and how they handle this in the Javascript sp= ace, they basically install compatible packages when possible, and only = 'contain' them when it would introduce an incompatibility. I have some ideas here, but I need some time to think on it; but I also = want to point out the problem to see if anyone else has any ideas. =E2=80=94 Rob --c6d792634d33400a9a2cfb128927d161 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Sat, May = 24, 2025, at 11:34, Rowan Tommins [IMSoP] wrote:


Hi Michae= l,

I'm going to skip over all the details about= the autoloader for now, because I think they're going deep into impleme= ntation details, and I want to focus on the same top-level design as my = previous email.


On 23 May 2025 0= 2:27:41 BST, Michael Morris <te= ndoaki@gmail.com> wrote:
>Bobs docs needs an older v= ersion of Monolog and is configured appropriately
>in its c= omposer.json file, so ... v1 is prefixed to the
>namespace = declarations in Monolog\Logger and the file is included. The
&= gt;engine aliases BobsDocs\Monolog\Logger to \v1\Monolog\Logger.


If I'm following correctly, you suggest= that we would end up with class names like this:

\v1\Monolog\Logger
\v2\Monolog\Logger
\v5\Google\= Client
\v7\Google\Client

It feels lik= e there's a lot of complexity in the package manager here - it's got to = keep track of which versions of each package are installed, what they de= pend on, and decide what prefixes need to be used where. You also sugges= t that one version of each package is left with no prefix, which adds ev= en more complexity.


>The Goog= l\ApiClient of BobDocs is again, up to the autoloader. Assuming it
=
>too is different (since it's using an older Monolog)
=
The biggest problem comes when this assumption doesn't ho= ld. I actually chose these particular packages to illustrate this proble= m, then left it out of my previous message. It happens that the latest v= ersion of google/apiclient supports both monolog/monolog 2.9 and 3.0, so= it's possible to have: 

- AlicesCalendar = wants to use google/apiclient 2.18 and monolog/monolog 2.9
- B= obsDocs wants to use google/apiclient 2.18 and monolog/monolog 3.0
=

If the package manager is adding prefixes to individ= ual package versions, we will have one class called \v2_18\Google\Client= containing our familiar "new Logger" line. AlicesCalendar will expect t= hat line to create a \v2_9\Monolog\Logger, but BobsDocs will expect it t= o create a \v3_0\Monolog\Logger. We can't please both of them without cr= eating an extra copy of Google\Client with a different prefix.

So the version of an individual package isn't enough to = decide the prefix, we need to know which *set* of packages it belongs to= . 


My suggestion uses a muc= h simpler rule to define the prefix: if it's loaded "inside" AlicesCalen= dar, add the prefix "\AlicesCalendar\". All the classes that are "inside= " are completely sandboxed from the classes "outside", without needing a= ny interaction with a package manager.

As far a= s I know, this is how existing userland solutions work, and I haven't ye= t spotted a reason why it needs to be any more complex than that.
<= div>

Regards,
Rowan Tommins
=
[IMSoP]


My onl= y concern is how this would be handled in the class tables. Right now, \= AlicesCalendar\Monolog\Logger and \BobsDocs\Monolog\Logger would be cons= idered entirely different types -- as in, not compatible. So if AlicesCa= lendar returns a type that BobsDocs expects, they won't be able to talk = to each other.

So, this means we'd need a coupl= e of different types of dependencies:
  1. "direct dependenc= ies" that work in a containerized way
  2. "parent dependencies" that= expect a parent to provide the dependency so it can interoperate betwee= n packages
I assume that it will be up to a dependency res= olver (either composer or something else) will need to figure out which = direct dependencies to "hoist" up and provide a compatible version betwe= en the two packages.

That then begs the questio= n of whether this complication is needed at all? I can understand why ha= ving a 'containerized' package system is useful (in the case of WordPres= s or plugins in general), but I'm wondering if it is actually needed?

If we look at npm and yarn and how they handle th= is in the Javascript space, they basically install compatible packages w= hen possible, and only 'contain' them when it would introduce an incompa= tibility.

I have some ideas here, but I need so= me time to think on it; but I also want to point out the problem to see = if anyone else has any ideas.

=E2=80=94 Rob
--c6d792634d33400a9a2cfb128927d161--