Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128669 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 7C62C1A00BC for ; Wed, 10 Sep 2025 19:58:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1757534204; bh=CuW5ETh1//P3c7rZR6DM4beNJSrtfduC0v1Y1jGuRJ4=; h=References:In-Reply-To:From:Date:Subject:To:From; b=ZN3jlLs82XQweTFUVjQoGtFwxjTPCS5nGvXRJc/AC9DRitjRZ/Xu+Xdt3zel/emHY UdqNMStDvbQWlT3akBqX0Hy75myB81B5NqhsBz+bQtzgelS4r03DuoWSRbqqHG/ULz /nAKw9aYu4bPQw0on2bQjFQzxFks1NLhgn+BKBoLVZB3hLQe4GjwH+qFeibElBa4Rg I5wXoj0IOd/CFGQTh48c997eun8n5RRAR+iVRZ0iuLibeRMeLeumEBaykS3VBKB4Hu Z1NByc0jHbvKwRkuIQ4VhGqcD3t/FmpA8c8cWyunA042RjqHl7V6gqU3265rzr0HiL ubK7VRBNwGg/A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4B3E2180032 for ; Wed, 10 Sep 2025 19:56:42 +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.1 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_FONT_LOW_CONTRAST,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,URI_HEX autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.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 ; Wed, 10 Sep 2025 19:56:41 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-323266cdf64so6386419a91.0 for ; Wed, 10 Sep 2025 12:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qbix-com.20230601.gappssmtp.com; s=20230601; t=1757534287; x=1758139087; 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=AwN3QkA3nLE/0gDnRqg1+53wZJLuyHceNtBIAK290Nc=; b=xnek0BdNSPwMeJttmtA3kctSZbGtzQ+Opme8OT3vZJixOlzK+DSvzdm7fM+njIcbzA 632E81Z2V7Y45yiFEsOIUp2Hv923P/XiCOPEsjoY8R5NSqCAyEk7bUaBo2EuHlcB5MVe L+b8ejFMxKbYRGp22OQS5spRvWNxp5I7jdB7wTfq4x/E9szIGypN8DcQ3599u/4M7lCT eVfG0DTPNXG8pzXIoaQbxFrgiOYAvzwx/vMnYaB+dBsCwICCHCzwQuEB2m9kK0yw/upc Dx8My0JKZtyyLrfuvNHW1vnTuKLNIDf5SYKJebfoxcmoUhDQ+N0W7AyRQZyB6HHB1How iSIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757534287; x=1758139087; 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=AwN3QkA3nLE/0gDnRqg1+53wZJLuyHceNtBIAK290Nc=; b=JgkNs6RtLt+BzV5ESkaSUjoLZADPljBX12R88V/8xVTI6PXoNSditwfVMmxlGYgIGe e3TyG++3J6OhE62xYvOXthtw0e5mhplIISd59j/eHSsIVbmNXh2RlH3odbbOPyPp58Fo T6n6XCc/dQJ6Ylc1zBpj2MS2JZtqA7ImE7/yaUkLaSE2B120ENTrEf+zjp0WcB6Wt7v+ tTJxNTs/ADjgsfF0Et5ebDvyWLQyeFQolGwBCtcQWr92Kr6bT8+IwE/wL9o2Ya+Wwo+y uuuhbUe3zBsRNi+U4+7ZGo7CirRE3HXOeO61lnqKmd6rcJl/oGKuWyXDzZUroakSrJr+ gubQ== X-Gm-Message-State: AOJu0Yy7TMaXk745DvShWNAZjevHOo8kpMmEJWDmUwzr2xkFpZlbFNKk kP08I2QjfRf+MgdQF1o/4fhJpyEom8S6xRu82vLikb+YsJdK5N7y5aNjRqXHLLp+kXhrGkgtqyf DM8mSJdWEm9W3pgAnM9oiD29yujTttwSiT1tx4MwcIE7+Hsndoajm+Pw= X-Gm-Gg: ASbGnctoiUXBVVoncRCUaZ327WOA91KcAm3KZZtjzwIkB83dEdakSGkhLS6+2ptAosZ 1A+y8vc3B1QBneqq6HTVy/EIGrY4C8Df4PffvTGxvMKP7mk/dYPki/p+yo5A2rZGw/K8pKLSrGG 6p8dJrnQKdCUcrEQx/iLc16TG/P9lCnGzigvu5jN+7vsg8it2Ke93tWM+vQ/6Obolbw02wKMmhP rjp4j1CJPo/WtzfQfeRR8unxcAY70gynrSFrg== X-Google-Smtp-Source: AGHT+IFo3YghFG5WnmE8kCcC9wlXUbag0DmYmOQTWA95LNisD+mEQXSuAiOvxRfk3XGaH5OPeEXHj7LQhrUZ1rZ9xu4= X-Received: by 2002:a17:90b:3e45:b0:32b:df31:3dc2 with SMTP id 98e67ed59e1d1-32d43f653cfmr20391354a91.22.1757534286753; Wed, 10 Sep 2025 12:58:06 -0700 (PDT) Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 10 Sep 2025 15:57:54 -0400 X-Gm-Features: Ac12FXwie8WVCe1z7R1dEDgZE-f8QsbKsSjTen_MBRWABghp7mIeNPlaFN2pQuA Message-ID: Subject: [PHP-DEV] Re: Three proposals for PHP 9 To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000d7cf26063e77d652" From: greg@qbix.com (Gregory Magarshak) --000000000000d7cf26063e77d652 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi everyone. Just wanted to follow up on this. Is there any chance of switch_global_context making it into PHP 9? This would be a huge game-changer as e.g. FrankenPHP in worker mode could literally be up to 100x faster than PHP-FPM! But right now, most frameworks which benefit from the awesome shared-nothing architecture (using static Foo::$bar, superglobals, PDO, etc.) are stuck, and need a complete rewrite. With this, they wouldn't. I understand that switch_global_context() might have a bit of trouble with database pools or whatnot (since some connections wouldn't be released) and therefore would actually end up making a process block until the connections are available. This may be tricky. But the goal of porting all existing PHP code to take advantage of worker mode is extremely worth it, even if some threads end up blocked temporarily it's still strictly faster and better than PHP-FPM and FrankenPHP classic mode. Sincerely, Greg Magarshak On Tue, Jul 29, 2025 at 1:46=E2=80=AFPM Gregory Magarshak w= rote: > I came across this post on Reddit asking what people would like to see in > the next PHP: https://www.reddit.com/r/PHP/s/l9r8UJP6Rk > > There are two major proposals I would make, both of which aim to greatly > improve PHP's competitiveness and ecosystem, while maintaining its spirit > and what makes it great. And one minor proposal. I wrote them on Reddit, > but then I realized I should actually do something about it. The last tim= e > I did something was in 2015 writing to the PHP list back then. > > How do I get rights to create my own RFCs for these? I tried to do it on > the web, but it says to ask on the mailing list. Here are my bona fides: > I've spent about 20 years with PHP, to be honest, and the last 14 buildin= g > an open-source community platform / CMS that competes with Facebook, > Twitter, etc. and uses very idiomatic PHP. Here are two links in case > anyone is interested > https://github.com/Qbix > https://www.laweekly.com/restoring-healthy-communities/ > > Anyway without further ado, I would like to present the two proposals: > > First one: introduce switch_global_context($name) > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > I really love PHP=E2=80=99s shared-nothing architecture, but when it come= s to > frankenphp, swoole etc. it is very hard to port existing apps to that > evented runtime. That is mainly because the superglobals and static > variables are =E2=80=94 well =E2=80=94 global. You can have the best of b= oth worlds. > > Just add a function to PHP which can do context switching between all > global scopes, to any named scope. So when you have one evented runtime, = it > can quickly switch. This should be easy to do with SHM (shared memory > segments) and just pointing to a different page in memory. > > The goal is to allow all =E2=80=9Clegacy=E2=80=9D code (ie all current PH= P code that runs > on php-fpm etc) to be trivially ported to much faster runtimes, while > remaining =E2=80=9Cshared-nothing=E2=80=9D for all intents and purposes (= global contexts > would be isolated from one another because only one could be active at a > time). > > Second one: set_encryption_seed($name) > > You might need to let people register functions to run before a context i= s > saved (sleep) and after it is loaded (wakeup), when there is memory > pressure, PHP can handle this in a standard way and even encrypt it at > rest. You can also do this for session save/open handlers (which you > already do). > > Just have an environment variable or function like > set_encryption_seed($seed) at startup of frankenphp or swoole. > > Third one one: Improve func_get_args to return associative arrays. > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > I had this suggestion back in 2015 but maybe now it=E2=80=99s outdated. Y= ou see, > functions typically start out having required arguments first, then add o= n > optional arguments later. I thought based on how PHP passes arguments, it > would have been trivial to enhance func_get_args to return an array index= ed > not just by numeric values but also string values! > > And therefore one could pass arguments like in python: func(2, 5, $foo = =3D> > $bar, $baz =3D> $choo) It also would look exactly like the familiar array > composition syntax. But this is no mere syntactic sugar. It helps > developers fall into the pit of success by creating backward-compatible > interfaces and making any function extensible, improving the entire > ecosystem. > > Sincerely, > Greg Magarshak > > > > =E1=90=A7 > =E1=90=A7 > =E1=90=A7 --000000000000d7cf26063e77d652 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi everyone. Just wanted to follow u= p on this. Is there any chance of switch_global_context making it into PHP = 9? This would be a huge game-changer as e.g. FrankenPHP in worker mode coul= d literally be up to 100x faster than PHP-FPM! But right now, most framewor= ks which benefit from the awesome shared-nothing architecture (using static= Foo::$bar, superglobals, PDO, etc.) are stuck, and need a complete rewrite= . With this, they wouldn't.

I understand that switch_global_cont= ext() might have a bit of trouble with database=C2=A0pools or whatnot (sinc= e some connections wouldn't be released) and therefore would actually e= nd up making a process block until the connections are available. This may = be tricky. But the goal of porting all existing PHP code to take advantage = of worker mode is extremely worth it, even if some threads end up blocked t= emporarily it's still strictly faster and better than PHP-FPM and Frank= enPHP classic mode.

Sincerely,
Greg Magarshak


<= /div>


3D""
On Tu= e, Jul 29, 2025 at 1:46=E2=80=AFPM Gregory Magarshak <greg@qbix.com> wrote:
I came a= cross this post on Reddit asking what people would like to see in the next = PHP: https://www.reddit.com/r/PHP/s/l9r8UJP6Rk

Th= ere are two major proposals I would make,=C2=A0 both of which aim to greatl= y improve PHP's competitiveness and ecosystem, while maintaining its sp= irit and what makes it great. And one minor proposal. I wrote them on Reddi= t, but then I realized I should actually do something about it. The last ti= me I did something was in 2015 writing to the PHP list back then.

How do I get rights to create my own RFCs for these? I trie= d to do it on the web, but it says to ask on the mailing list. Here are my = bona fides: I've spent about 20 years with PHP, to be honest, and the l= ast 14 building an open-source community platform / CMS that competes with = Facebook, Twitter, etc. and uses very idiomatic PHP. Here are two links in = case anyone is interested

A= nyway without further ado, I would like to present the two proposals:
=

First one: introduce switch_global_context($name)
=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

I really= love PHP=E2=80=99s shared-nothing architecture, but when it comes to frank= enphp, swoole etc. it is very hard to port existing apps to that evented ru= ntime. That is mainly because the superglobals and static variables are =E2=80=94 = well =E2=80=94 global. You can have the best of both worlds.

Just add a f= unction to PHP which can do context switching between all global scopes, to= any named scope. So when you have one evented runtime, it can quickly swit= ch. This should be easy to do with SHM (shared memory segments) and just po= inting to a different page in memory.=C2=A0

The go= al is to allow all =E2=80=9Clegacy=E2=80=9D code (ie all current PHP code t= hat runs on php-fpm etc) to be trivially ported to much faster runtimes, wh= ile remaining =E2=80=9Cshared-nothing=E2=80=9D for all intents and purposes= (global contexts would be isolated from one another because only one could= be active at a time).

Second one: set_encryption_= seed($name)

You might need to let people register = functions to run before a context is saved (sleep) and after it is loaded (= wakeup), when there is memory pressure, PHP can handle this in a standard w= ay and even encrypt it at rest. You can also do this for session save/open = handlers (which you already do).

Just have an envi= ronment variable or function like set_encryption_seed($seed) at startup of = frankenphp or swoole.

Third one one: Improve func_= get_args to return associative arrays.
=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

I had this sugge= stion back in 2015 but maybe now it=E2=80=99s outdated. You see, functions = typically start out having required arguments first, then add on optional a= rguments later. I thought based on how PHP passes arguments, it would have = been trivial to enhance func_get_args to return an array indexed not just b= y numeric values but also string values!

And there= fore one could pass arguments like in python: func(2, 5, $foo =3D> $bar, $baz =3D> $choo) It also would look exactly like the familiar array composition syntax. But = this is no mere syntactic sugar. It helps developers fall into the pit of s= uccess by creating backward-compatible interfaces and making any function e= xtensible, improving the entire ecosystem.

=
Sincerely,
Greg Magarshak<= br>

3D""
3D""=E1=90=A7
3D""
3D"==E1=90=A7
3D""=E1=90=A7
--000000000000d7cf26063e77d652--