Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127343 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 E40EF1A00BC for ; Tue, 13 May 2025 18:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747161549; bh=ozJ9UZW3dosiTOJ5Qe/Gyad6YjlsK48NzOr6+iqso4M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=U8sHhgzEj2KbOseFo2oWYmJGf6alZMcrnJ7DgMpZodrrPPeDXMMfpX7PloXD8dE4V u3zExLhFZNzYANIQbEYfIgcVXfZI+hkVa0DcK/xEfAzqCX7A6z/ysFAOj1YbNfmb7q iiAWQZ4jo4RiHGCAuaghX8NiWZ2iiDnVw/ECnEL5Yiyn+b0nwSMk9FeciQt8hkjPz7 dZAc7EeJXmACcIr9stm3E0FkLdF2z7209PQ/8gv/Jm8MGyL1l+axU5hNTb74aE8Hc8 wiRiSkp4TeGpnbbSYhXJ/Ael1syIXUEqSN5Pknb6ZqYI1Xjf/bsZAYkGBEwU974+HW 3JIcPg75HZcMQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DA38518006C for ; Tue, 13 May 2025 18:39:07 +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-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) (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 ; Tue, 13 May 2025 18:39:04 +0000 (UTC) Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-e733cd55f9eso6029274276.1 for ; Tue, 13 May 2025 11:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747161675; x=1747766475; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JqZxO+cS8/Fa/6BVXYWCiaFybezbpUBbdu5G26KRfZY=; b=jxe/QIUfZEHAK1GukuP8vs7iFM0WJODsFW4doThNCFqJBUQKx0P/xJqvFWtU+nui+Y oaEK6P3+25OpdV0GXFMsdyXdCdjuXFD1pgWlaMcyz3GjG/N/dtmAZwqW8qDdvpOucrjU 3e6HzXgepEtkKQRdVsxUI69X1Egmn1wurUHDjcf0Jf4dIhyu9aUPamq+mf5ZG4enhM0m ytqW4OLFbO9nE2V2ppFWwinmeV+k5ue8xtRODRkat/J/VHXG0H0UWCy+k55lnMrAjOhC gHWbsUUNbOfJjWwWMaz0pYrNxePu4ViDJtHNix2w8tmBBMvDNBvnS7eiNTsVSpfFWSR2 F9Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747161675; x=1747766475; h=cc: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=JqZxO+cS8/Fa/6BVXYWCiaFybezbpUBbdu5G26KRfZY=; b=D+pgaNdad8KghCB+8WUiRY5SFyvBRpfD4T7lVSC9zEYk0xBoJydAJ+OjvlG0f+ZgdF aQsUT/Ih/8wrPUHD6zneM84AAfVJHobxFSw9e+wetGiRlCEldN5lQT4VCseLiBPHSq4p 3IjBDqATDBLkt85JXHNiKwxaBZnZLFCdEywVDhH+H64bAZzDGwCdR4mn2Gy81YxNMaj0 fDz9Br0nv+qG81jy1a6KeP3OmzjrHmAQ7fdc4Pmk45RwfkJr8WEL67Flt1DtYtYUM6+X 8UkA9cONGHeaOWjZfdGoB23Z/Zi/hy90SkMgF1Knjr8CLAs0wI2mhiexYlNN7QYPq803 boSA== X-Gm-Message-State: AOJu0YwFliqQP5fW+Zo8zrzp8dbLS+Pu4DhO9W96wmS6F8sI2Zlq1rSx j/2l8baIYa8ZnQTgTKqMypCAi2jsTDYYWZNtruReRFPCs1zs7UPfD6mS/S/iYtTMb/aPVa72HlT NpJX01kAhvB+oGV1+xaHD+BqdK2Y= X-Gm-Gg: ASbGncugdamMOxvNY3Jj593tRIO55A9Twtawb1a1U8e5ZbyS/4rmZLEEWbrs4xzL26B mMERVDJDOjLIhgO6pjJERNCjCwun8BkQreFdZNnGvV272tMo1iVy+4rgk75pJIOmpdTRmJLIZak dAxmIoQqSP5iWhC5HTs9BT4aG7JR6RYeJYGb+7h1AzFA== X-Google-Smtp-Source: AGHT+IGvdGikuFeHse/ZAZ+oaK7UJ8qJj3jGx3P8s0MUgw/MQ82gGQ2tBs2MR/qsYQtT/Ay0PHEMg1d5++DGjKPpp7I= X-Received: by 2002:a05:6902:e92:b0:e74:f068:4df1 with SMTP id 3f1490d57ef6-e7b3d50a81amr560436276.22.1747161675221; Tue, 13 May 2025 11:41:15 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 13 May 2025 21:41:03 +0300 X-Gm-Features: AX0GCFupJ-WPhwl1KFf4ONlVi7R5Z16b4vfJYIeW1o51WMJ1aRYHaHBr7xRjP6Q Message-ID: Subject: Re: [PHP-DEV] Module or Class Visibility, Season 2 To: Deleu Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000045256063508c72e" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000045256063508c72e Content-Type: text/plain; charset="UTF-8" On Tue, May 13, 2025, 18:35 Deleu wrote: > Hi! > > It's been a few days since I wanted to send this email to internals, but > real life has been a bit chaotic so I apologize if it comes off as if I > didn't research the archives enough. I glossed over the Module conversation > from 10 months ago and the one that recently surfaced and after deeply > thinking about Rowan's and Larry's comments I wanted to throw this idea > into the pit. > > Lets preface the conversation with the fact that 1) a module system for > PHP has been discussed for several years and 2) if there was an easy and > perfect solution it would have been long implemented by now. > > If we consider how GitHub, Composer and Docker Hub works, we can pin a > very important aspect of "namespaces": {entity}/{project}. > Hi, thank you for starting this thread. I have a similar thing, an idea that was sitting on my mind that I want to put in writing, so I will share it here. First of all, I want to acknowledge the problems with big projects, big monoliths that can only have one composer.json and many libraries needed, that would eventually clash and make upgrades harder than they need to be. Can we develop the modules concept without linking ourselves to namespaces or any other new entity? I think it might be possible, if every symbol that is defined is attached to a module when it is loaded. And we can use something like: ``` module(string $name, callable $closure); ``` The $closure is defined in the current module, but is executed in the new module. Anything else follows the logic: the functions and methods are executed in the module where they are defined and associated with. Any new symbols defined inherit the current module. When a module is defined by another parent module, a relation will be created between them and the parent module would get access to the child module symbols, but not also the other way around. There is no need to change anything on the libraries code but only on composer and autoloading. That is the key point for easy adoption. Composer-related, each installed package will be loaded in their own module. What is yet to figure out: - can we define internal modules, where the child module symbols are visible only in the parent defining module and not any level up? - once a module defined, can the parent - child relation be redefined/changed/removed? I apologize if this changes the solution discussion, but I didn't wanted to start a new thread on the same topic. -- Alex --000000000000045256063508c72e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, May 13, 2025, 18:35 Dele= u <deleugyn@gmail.com> wrot= e:
Hi!
<= div>
It's been a few days since I wanted to send this ema= il to internals, but real life has been a bit chaotic so I apologize if it = comes off as if I didn't research the archives enough. I glossed over t= he Module conversation from 10 months ago and the one that recently surface= d and after deeply thinking about Rowan's and Larry's comments I wa= nted to throw this idea into the pit.

Lets preface= the conversation with the fact that 1) a module system for PHP has been di= scussed for several years and 2) if there was an easy and perfect solution = it would have been long implemented by now.=C2=A0

= If we consider how GitHub, Composer and Docker Hub works, we can pin a very= important aspect of "namespaces": {entity}/{project}.

Hi, thank you for starting this thread.

I have a similar thing, an idea th= at was sitting on my mind that I want to put in writing, so I will share it= here.

First of all, I w= ant to acknowledge the problems with big projects, big monoliths that can o= nly have one composer.json and many libraries needed, that would eventually= clash and make upgrades harder than they need to be.

Can we develop the modules concept without li= nking ourselves to namespaces or any other new entity?

I think it might be possible, if every symbo= l that is defined is attached to a module when it is loaded.
And we can use something like:
```
module(string $name, callable $closure);
```

The $closure is= defined in the current module, but is executed in the new module.
Anything else follows the logic: the functions and methods a= re executed in the module where they are defined and associated with. Any n= ew symbols defined inherit the current module.

<= /div>
When a module is defined by another parent module, a= relation will be created between them and the parent module would get acce= ss to the child module symbols, but not also the other way around.

There is no need to change anyth= ing on the libraries code but only on composer and autoloading. That is the= key point for easy adoption.
Composer-related, each= installed package will be loaded in their own module.

What is yet to figure out:
=C2=A0- can we define internal modules, where the child module symbol= s are visible only in the parent defining module and not any level up?
=C2=A0- once a module defined, can the parent - child re= lation be redefined/changed/removed?


I apologize if this changes the so= lution discussion, but I didn't wanted to start a new thread on the sam= e topic.

--=C2=A0
<= div dir=3D"auto">Alex

=
--000000000000045256063508c72e--