Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127361 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 A1D721A00BC for ; Wed, 14 May 2025 20:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747255709; bh=jI35uA4uMCPg0gTROSYyMp8COjT7qcRhFiYhtbK35DQ=; h=References:In-Reply-To:From:Date:Subject:To:From; b=Wl29mKxEWptjxFefvaNUm5bvl46aiyWcc5HTw2KpVqHBBjjZWkBasP4iLF2PlBEpq iR1ImUGDI8YUX86OqQ4kH7bnFenYVHa2+JEVJIlTSmVkYg+6Y7TaFg3rbCyAhqSpVP eOZGFMaTPsZ3FGg/t52fic50k4YVTQY+A3qEzU6WMgnzYyEQ1+twzIuw4MgI0QDD0O t0dUT7oD+lYzDp1VpQqcWC+q8c3onFG4vtiNGXm+ysAu1pTW8ZTYo3XgZl9QORZBWE Fi7CDdZcEWPxbqjOXG7xNF3+7E+6DwuZBDPxrs/pupu1ZXLzPA4j/nAtcSeYWFhVzL 62fSa2o6klQ4A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5EFEC180053 for ; Wed, 14 May 2025 20:48:28 +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-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (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, 14 May 2025 20:48:28 +0000 (UTC) Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-7c5b8d13f73so24141285a.0 for ; Wed, 14 May 2025 13:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747255838; x=1747860638; 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=X3M/lMwrUryy8tKk2rhlRmr6DBg3h8TnuGh4jwYSSJ0=; b=eP+Wb0kfFG2KNGI1JPmNU1JoPqwn23xchxrarG4UIgSh5Qe8eMVJcQGz6d2RSC+ggF DwrMKKgGImtIDn9mL7A8gOvUemiLtopKYmdVDvY2aYkGMc6D3uRA62H1Yc1BOXVqKKwv ++XbinVgS1SKmxy7ZJIa7ZNJFR/91NjVWHGwfNxhRyaQiO7u9coCmNwVvNyGgWxDRZJQ SAf5m2O3kFhhWNTNPzEyodguRxemJWioOnj4QhRRiqXFDQdFUI27yIKm8+rP3IGolSw6 NvYHn8wltOqNZopROfGBVSH7F8oNwXn27LtjYsK3uA+SrEC7xU5VcgMOKbvPBwlKSHZd hfTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747255838; x=1747860638; 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=X3M/lMwrUryy8tKk2rhlRmr6DBg3h8TnuGh4jwYSSJ0=; b=KZYAGVUDvu3KA4qIPNX6JihVf4g37AT3R0eR2sw3YYfODgKizgDXQPa1pd51nqjJq7 TbzAUNRX8x3+EmFKkNKP9YsuoJJOYigcyvf5ESvE5d5pzs35nnRYrJHzA7Qvg1P/Ajdn USIrAigcvZ8DVBQeXlPym8MV8RWSKMmzSfouGfbBtcxM20LCkEGyWYS+YndA96ckP6yA 3bzJCryLXy4ExfoLslMaH6FeEpmXPCBsIYT8xBcgiHaU1QJYo2bqUWDGGPy3b7sDa5EP TP1KS22YxZg/J+kNQRlsIaCSySmJMiixwqGNLw7J8GPZszgBk32V9QuaEQN90sm8gXd1 tjxA== X-Gm-Message-State: AOJu0YwJumVdPqx+qcrUsXzRheKzaSPfPS0pAS75xFz8+P7xH6w9/10m k+OusAOJv07Vwsat2wd1CUqJKWrIBgN5eRGEXbEFcRXtHzqrdtOG26ou3Jd0RzzXSiTNvLV49QB hqzdLd2v8RfNXgch6m7WL3hKywuL0UQ== X-Gm-Gg: ASbGncuXkrVBbrahG4zyho9ONok+AwP+w1EjD9PzGYo9HvW0lsijT6VTluHA86YV9mb fTUPujDIcMRNHIThUpdkEGn/RXDKwGrSD+1ymbml7E9MQz9A1LuKR1ZBqyDnvw0eeVdVhoVJ4ee z/EEmT5pxkv7xI2CV/Y5k8tjMOraWHwe+J+hGaQMbiyt7gKw/MIJo136D2O1aK6oWWYdyTh99lD Q== X-Google-Smtp-Source: AGHT+IGycxgnUZUbcYcK5Og1n/JZ55iiB+G4RqP+0yiPxWr/ikhEH/IF0laeShnVbgn9VaoMLUy5LV+LCV0f/1X0r+Q= X-Received: by 2002:ad4:5e85:0:b0:6f8:8df1:655 with SMTP id 6a1803df08f44-6f896ed808emr66493316d6.29.1747255837976; Wed, 14 May 2025 13:50:37 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <3ae9a6ea-f135-472b-b2bf-e6cd6ebad299@app.fastmail.com> <9A26F72B-D0EF-414F-B193-BED3CAB26A0B@rwec.co.uk> In-Reply-To: <9A26F72B-D0EF-414F-B193-BED3CAB26A0B@rwec.co.uk> Date: Wed, 14 May 2025 16:50:25 -0400 X-Gm-Features: AX0GCFspTcZzrci1XR4ikc0RBteh6LjBF6vLbqzm6AC3OWb8Tm0tijk92zomrrY Message-ID: Subject: Re: [PHP-DEV] Module or Class Visibility, Season 2 To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000008ded9706351eb3f2" From: tendoaki@gmail.com (Michael Morris) --0000000000008ded9706351eb3f2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 14, 2025 at 10:57=E2=80=AFAM Rowan Tommins [IMSoP] wrote: > > I don't know much about Go, but at a glance it uses a similar model to > JavaScript and Python where *classes don't have a universal name*, the > names are always local. That's not a different kind of module, it's a > fundamentally different *language design*. > > That said, they call them modules. I'm not going to argue with them, what do I know? > If you want to use two different versions of Guzzle in the same > application, the first problem you need to solve has nothing to do with > require, or autoloading, or Phar files. The first problem you need to sol= ve > is that you now have two classes called \GuzzleHttp\Client, and that brea= ks > a bunch of really fundamental assumptions. Your fundamental assumption is that the different versions are loaded onto the same symbol. Given the problems you outline yourself, why do that? You see, PHP doesn't have a mechanism for symbol changing at compile time. Everything loads onto the root. Does it *have* to be that way? Or can a file compile onto a namespace, effectively prefixing that namespace. > > > For example: > - plugin1 uses Guzzle v5, runs "$client1 =3D new \GuzzleHttp\Client", and > returns it to the main application > - The main application passes $client1 to plugin2 > - plugin2 uses Guzzle v4 > plugin2 runs "$client2 =3D new \GuzzleHttp\Client" > If plugin 2 wants to use version 4 for whatever reason, why can't it load it into \Plugin2\GuzzleHttpClient instead of onto the root?? This is what userland monkey-typers like Strauss do. It works, but there are issues with this solution outlined elsewhere. > That's why I think "containers" are the more useful comparison - you need > some way to put not just plugin1 itself, but all the third-party code it > calls, into some kind of sandbox, as though it was running in a separate > process. If you can control what classes can go into and out of that > sandbox, then in any piece of code, you don't end up with conflicting > meanings for the same name - just as a Linux container can't open a netwo= rk > port directly on the host. > Container, module, block, package, plugin, domain, division, fraction, lump, branch, sliver, splinter, constituent or whatever the hell else you call it, I don't care. What I need is a way to manage package version conflicts which arise in the real world when plugins get abandoned or when coordinating having everyone change dependencies at the same time isn't feasible. --0000000000008ded9706351eb3f2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Wed, May 14,= 2025 at 10:57=E2=80=AFAM Rowan Tommins [IMSoP] <imsop.php@rwec.co.uk> wrote:

I don't know much about Go, but at a glance it uses a similar model to = JavaScript and Python where *classes don't have a universal name*, the = names are always local. That's not a different kind of module, it's= a fundamentally different *language design*.


That said, they call them modules. I&#= 39;m not going to argue with them, what do I know?
=C2=A0
If you want to use two different versions of Guzzle in the same application= , the first problem you need to solve has nothing to do with require, or au= toloading, or Phar files. The first problem you need to solve is that you n= ow have two classes called \GuzzleHttp\Client, and that breaks a bunch of r= eally fundamental assumptions.

Your fundame= ntal assumption is that the different versions are loaded onto the same sym= bol.=C2=A0 Given the problems you outline yourself, why do that?
=
You see, PHP doesn't have a mechanism for symbol changin= g at compile time. Everything loads onto the root.=C2=A0 Does it *have* to = be that way? Or can a file compile onto a namespace, effectively prefixing = that namespace.
=C2=A0


For example:
- plugin1 uses Guzzle v5, runs "$client1 =3D new \GuzzleHttp\Client&qu= ot;, and returns it to the main application
- The main application passes $client1 to plugin2
- plugin2 uses Guzzle v4
plugin2 runs "$client2 =3D new \GuzzleHttp\Client"

If plugin 2 wants to use version 4 for whatever reaso= n, why can't it load it into \Plugin2\GuzzleHttpClient instead of onto = the root??

This is what userland monkey-typers=C2= =A0like Strauss do. It works, but there are issues with this solution outli= ned elsewhere.


That's why I think "containers" are the more useful compariso= n - you need some way to put not just plugin1 itself, but all the third-par= ty code it calls, into some kind of sandbox, as though it was running in a = separate process. If you can control what classes can go into and out of th= at sandbox, then in any piece of code, you don't end up with conflictin= g meanings for the same name - just as a Linux container can't open a n= etwork port directly on the host.

Conta= iner, module, block, package, plugin, domain, division, fraction, lump, bra= nch, sliver, splinter, constituent or whatever the hell else you call it, I= don't care. What I need is a way to manage package version conflicts w= hich arise in the real world when plugins get abandoned or when coordinatin= g having everyone change dependencies at the same time isn't feasible.<= /div>
--0000000000008ded9706351eb3f2--