Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-05 Thread Deleu
On Fri, Jan 5, 2024 at 9:40 AM Michał Marcin Brzuchalski < michal.brzuchal...@gmail.com> wrote: > There are indeed dozens of libraries already working with PSR nicely but > IMHO > the API should provide all the necessary information in a way that allows > the construction of such objects, > but

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-05 Thread Rowan Tommins
On 5 January 2024 12:18:51 GMT, Robert Landers wrote: >This is easy to handle from C. If the callback takes an argument, >don't fill in the super-globals. Again, that's compatible only in a narrow sense: it provides both APIs on any run-time which can do so safely. You still have an

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-05 Thread Michał Marcin Brzuchalski
pt., 5 sty 2024 o 13:19 Robert Landers napisał(a): > On Fri, Jan 5, 2024 at 11:59 AM Rowan Tommins > wrote: > > > > Globals is how this works (atm) > > > > It's how it works for native SAPIs. It's not, as far as I know, how any > worker system other than FrankenPHP has implemented its API.

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-05 Thread Robert Landers
On Fri, Jan 5, 2024 at 11:59 AM Rowan Tommins wrote: > > On 5 January 2024 09:02:05 GMT, Robert Landers > wrote: > > I don't think they are fundamentally incompatible. If we look at > >FrankenPHP's implementation, you pass a callback that gets called when > >there is a request. > > No, you pass

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-05 Thread Rowan Tommins
On 5 January 2024 09:02:05 GMT, Robert Landers wrote: > I don't think they are fundamentally incompatible. If we look at >FrankenPHP's implementation, you pass a callback that gets called when >there is a request. No, you pass a callback which is called exactly once, for the next request. You

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-05 Thread Daniil Gentili
Hi, > But holding up the entire conversation because these things don't even > exist, BTW, I'm not asking to wait for the implementation of a native event loop before implementing a worker mode, I'm asking to design the worker mode API in a way that is compatible with an eventual native event

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-05 Thread Robert Landers
On Fri, Jan 5, 2024 at 8:47 AM Rowan Tommins wrote: > > On 5 January 2024 06:55:34 GMT, Robert Landers > wrote: > > >I already said this, but to reiterate: I, personally, hear what you > >are saying and largely agree with you; however, before we can really > >have any kind of discussion on

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-04 Thread Rowan Tommins
On 5 January 2024 06:55:34 GMT, Robert Landers wrote: >I already said this, but to reiterate: I, personally, hear what you >are saying and largely agree with you; however, before we can really >have any kind of discussion on concurrent servers, we HAVE to address >the underlying issues that are

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-04 Thread Robert Landers
On Fri, Jan 5, 2024 at 2:56 AM Daniil Gentili wrote: > > Hi, > > I've been lurking around in the discussion for a while, and I'd like to chime > in now since the main, glaring issue with this proposal has only been > explicitly mentioned by Rowan Tomminis, with that subthread quickly >

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-04 Thread Daniil Gentili
Hi, I've been lurking around in the discussion for a while, and I'd like to chime in now since the main, glaring issue with this proposal has only been explicitly mentioned by Rowan Tomminis, with that subthread quickly degenerating with misguided replies. PHP as a language absolutely needs a

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-02 Thread Jakub Zelenka
On Tue, Jan 2, 2024 at 3:46 PM Jeffrey Dafoe wrote: > > > Again, the representation as objects isn't a key requirement. Python's > > > WSGI spec simply has a dictionary (read: associative array) of the > > > environment based on CGI. The application might well turn that into a > > > more

RE: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-02 Thread Jeffrey Dafoe
> > Again, the representation as objects isn't a key requirement. Python's > > WSGI spec simply has a dictionary (read: associative array) of the > > environment based on CGI. The application might well turn that into a > > more powerful object, but standardisation of such wasn't considered a > >

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-01 Thread Rowan Tommins
I'm running out of different ways to say the same thing, and not really sure which part of my previous messages people haven't understood. I'm really not saying anything very controversial or complicated, just "had you considered that style B would offer these additional possibilities over

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-01 Thread Robert Landers
On Mon, Jan 1, 2024 at 12:18 PM Rowan Tommins wrote: > > On 31 December 2023 16:31:31 GMT, Pierre Joye wrote: > > >php handles this in threadsafe mode > > Depending on your exact definition of "php", this is either irrelevant or > just plain wrong. > > If you mean "the HTTP SAPIs shipped with

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-01 Thread Pierre Joye
On Mon, Jan 1, 2024, 6:18 PM Rowan Tommins wrote: > On 31 December 2023 16:31:31 GMT, Pierre Joye > wrote: > > >php handles this in threadsafe mode > > Depending on your exact definition of "php", this is either irrelevant or > just plain wrong. > > If you mean "the HTTP SAPIs shipped with

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2024-01-01 Thread Rowan Tommins
On 31 December 2023 16:31:31 GMT, Pierre Joye wrote: >php handles this in threadsafe mode Depending on your exact definition of "php", this is either irrelevant or just plain wrong. If you mean "the HTTP SAPIs shipped with official builds of PHP", then it's true, none handle multiple

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-31 Thread Pierre Joye
hello, On Sun, Dec 31, 2023, 6:59 PM Rowan Tommins wrote: Then one of us is missing something very fundamental. As I understand it, > Swoole's model is similar to that popularised by node.js: a single thread > processes multiple incoming requests concurrently, using asynchronous I/O. The

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-31 Thread Rowan Tommins
On 31 December 2023 08:31:16 GMT, "Kévin Dunglas" wrote: >This new function is intended for SAPIs. Swoole was given as an example of >worker mode, but it isn't a SAPI. AFAIK, it doesn't use the SAPI >infrastructure provided by PHP. >The scope of my proposal is only to provide a new feature in the

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-31 Thread Kévin Dunglas
On Sun, Dec 31, 2023 at 2:20 AM Rowan Tommins wrote: > On 30 December 2023 19:48:39 GMT, Larry Garfield > wrote: > >The Franken-model is closer to how PHP-FPM works today, which means that > is easier to port existing code to, especially existing code that has lots > of globals or hidden

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-30 Thread Rowan Tommins
On 30 December 2023 19:48:39 GMT, Larry Garfield wrote: >The Franken-model is closer to how PHP-FPM works today, which means that is >easier to port existing code to, especially existing code that has lots of >globals or hidden globals. (Eg, Laravel.) That may or may not make it the >better

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-30 Thread Michał Marcin Brzuchalski
Hi Larry, sob., 30 gru 2023 o 20:49 Larry Garfield napisał(a): > On Sat, Dec 30, 2023, at 4:53 AM, Rowan Tommins wrote: > > On 30 December 2023 09:59:07 GMT, Robert Landers > > wrote: > >>For this to happen in PHP Core, there would need to be request objects > >>instead of a global state. > >

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-30 Thread Larry Garfield
On Sat, Dec 30, 2023, at 4:53 AM, Rowan Tommins wrote: > On 30 December 2023 09:59:07 GMT, Robert Landers > wrote: >>For this to happen in PHP Core, there would need to be request objects >>instead of a global state. > > Again, the representation as objects isn't a key requirement. Python's >

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-30 Thread Rowan Tommins
On 30 December 2023 09:59:07 GMT, Robert Landers wrote: >For this to happen in PHP Core, there would need to be request objects >instead of a global state. Again, the representation as objects isn't a key requirement. Python's WSGI spec simply has a dictionary (read: associative array) of the

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-30 Thread Michał Marcin Brzuchalski
Hi Robert, sob., 30 gru 2023, 10:59 użytkownik Robert Landers napisał: > > > - FrankenPHP expects the user to manage the main event loop ... > > > > > > > > > This isn't exact. FrankenPHP does manage the event loop (the Go > > > runtime manages it - through a channel - under the hood). > >

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-30 Thread Robert Landers
> > - FrankenPHP expects the user to manage the main event loop ... > > > > > > This isn't exact. FrankenPHP does manage the event loop (the Go > > runtime manages it - through a channel - under the hood). > > > Perhaps "event loop" was the wrong term; what I was highlighting is that > to use

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-30 Thread Michał Marcin Brzuchalski
Hi Rowan, pt., 29 gru 2023 o 23:56 Rowan Tommins napisał(a): > On 29/12/2023 21:14, Kévin Dunglas wrote: > ... > The use of objects vs arrays wasn't the main difference I was trying to > highlight there, but rather the overall API of how information gets into > and out of the application.

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-29 Thread Rowan Tommins
On 29/12/2023 21:14, Kévin Dunglas wrote: On Fri, Dec 29, 2023 at 8:14 PM Rowan Tommins wrote: - FrankenPHP expects the user to manage the main event loop ... This isn't exact. FrankenPHP does manage the event loop (the Go runtime manages it - through a channel - under the hood).

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-29 Thread Kévin Dunglas
On Fri, Dec 29, 2023 at 8:14 PM Rowan Tommins wrote: > - FrankenPHP expects the user to manage the main event loop, repeatedly > passing the server a function to be called once; it doesn't pass > anything into or out of the userland handler, instead resetting global > state to mimic a non-worker

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-29 Thread Rowan Tommins
On 23/12/2023 20:34, Kévin Dunglas wrote: In addition to sharing code, maintenance, performance optimization, etc., the existence of a common infrastructure would standardize the way worker scripts are created and provide a high-level PHP API for writing worker scripts that work with all SAPIs

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-26 Thread Tim Düsterhus
Hi On 12/25/23 19:56, Jordan LeDoux wrote: So you want to introduce a SAPI that doesn't work with any of the existing HTTP solutions people use that only supports HTTP requests? Or am I misunderstanding something? This sounds a bit like you want to merge in a tool that is designed for your

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Alexander Pravdin
> > So you want to introduce a SAPI that doesn't work with any of the existing > HTTP solutions people use that only supports HTTP requests? Or am I > misunderstanding something? > > This sounds a bit like you want to merge in a tool that is designed for > your personal product directly into core.

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Pierre Joye
Hello, On Tue, Dec 26, 2023, 1:56 AM Jordan LeDoux wrote: > > So you want to introduce a SAPI that doesn't work with any of the existing > HTTP solutions people use that only supports HTTP requests? Or am I > misunderstanding something? > > This sounds a bit like you want to merge in a tool

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Lanre Waju
Why not just build this into the embed sapi instead? since its only for third party sapis? On 2023-12-23 1:34 p.m., Kévin Dunglas wrote: Hello and Merry Christmas! One of the main features of FrankenPHP is its worker mode, which lets you keep a PHP application in memory to handle multiple

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Jakub Zelenka
Hi, On Tue, Dec 26, 2023 at 12:09 AM Robert Landers wrote: > Hi Jakub, > > > I have been thinking about something similar for FPM and if you had some > > sort pool manager process, you could maybe do some sort of initial > > execution but then it gets really tricky especially with sharing >

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Jakub Zelenka
On Mon, Dec 25, 2023 at 7:06 PM Kévin Dunglas wrote: > > On Mon, Dec 25, 2023 at 6:30 PM Jakub Zelenka wrote: > >> >> >> On Mon, Dec 25, 2023 at 12:34 PM Kévin Dunglas wrote: >> >>> On Sun, Dec 24, 2023 at 4:21 PM Larry Garfield >>> wrote: >>> >>> In practice, I want to understand the

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Robert Landers
Hi Jakub, > I have been thinking about something similar for FPM and if you had some > sort pool manager process, you could maybe do some sort of initial > execution but then it gets really tricky especially with sharing resources > and managing connections. I think it would be a big can of worms

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Kévin Dunglas
On Mon, Dec 25, 2023 at 7:56 PM Jordan LeDoux wrote: > > > On Mon, Dec 25, 2023 at 8:19 AM Kévin Dunglas wrote: > >> >> On Sun, Dec 24, 2023 at 10:44 PM Jordan LeDoux >> wrote: >> >>> >>> >>> On Sat, Dec 23, 2023 at 12:34 PM Kévin Dunglas wrote: >>> Hello and Merry Christmas!

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Kévin Dunglas
On Mon, Dec 25, 2023 at 6:30 PM Jakub Zelenka wrote: > > > On Mon, Dec 25, 2023 at 12:34 PM Kévin Dunglas wrote: > >> On Sun, Dec 24, 2023 at 4:21 PM Larry Garfield >> wrote: >> >> In practice, I want to understand the implications for user-space code. >> > Does this mean FPM could be

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Jordan LeDoux
On Mon, Dec 25, 2023 at 8:19 AM Kévin Dunglas wrote: > > On Sun, Dec 24, 2023 at 10:44 PM Jordan LeDoux > wrote: > >> >> >> On Sat, Dec 23, 2023 at 12:34 PM Kévin Dunglas wrote: >> >>> Hello and Merry Christmas! >>> >>> One of the main features of FrankenPHP is its worker mode, which lets you

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Jakub Zelenka
On Mon, Dec 25, 2023 at 12:34 PM Kévin Dunglas wrote: > On Sun, Dec 24, 2023 at 4:21 PM Larry Garfield > wrote: > > In practice, I want to understand the implications for user-space code. > > Does this mean FPM could be configured in a way to execute a file like > that > > shown in the docs

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Kévin Dunglas
> Forgive my ignorance, but why no connection? You mean the > pre-worker-start part needs to avoid an SQL connection? Why is that? That > would be something that needs to be super-well documented, and possibly > some guards in place to prevent it, if there's no good way around it. > (This is

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Larry Garfield
On Mon, Dec 25, 2023, at 6:34 AM, Kévin Dunglas wrote: > However, I suggest doing this as a second step, because as described in > my first post, it will still be the responsibility of each SAPI to > manage long-running processes and communication with them. This is > simple to do with Go's

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Kévin Dunglas
On Sun, Dec 24, 2023 at 10:44 PM Jordan LeDoux wrote: > > > On Sat, Dec 23, 2023 at 12:34 PM Kévin Dunglas wrote: > >> Hello and Merry Christmas! >> >> One of the main features of FrankenPHP is its worker mode, which lets you >> keep a PHP application in memory to handle multiple HTTP requests.

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-25 Thread Kévin Dunglas
On Sun, Dec 24, 2023 at 4:21 PM Larry Garfield wrote: In practice, I want to understand the implications for user-space code. > Does this mean FPM could be configured in a way to execute a file like that > shown in the docs page above? Or would it only work with third party SAPIs > like

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-24 Thread Jordan LeDoux
On Sat, Dec 23, 2023 at 12:34 PM Kévin Dunglas wrote: > Hello and Merry Christmas! > > One of the main features of FrankenPHP is its worker mode, which lets you > keep a PHP application in memory to handle multiple HTTP requests. > > Worker modes are becoming increasingly popular in the PHP

Re: [PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-24 Thread Larry Garfield
On Sat, Dec 23, 2023, at 2:34 PM, Kévin Dunglas wrote: > Hello and Merry Christmas! > > One of the main features of FrankenPHP is its worker mode, which lets you > keep a PHP application in memory to handle multiple HTTP requests. > > Worker modes are becoming increasingly popular in the PHP

[PHP-DEV] RFC proposal: worker mode primitives for SAPIs

2023-12-23 Thread Kévin Dunglas
Hello and Merry Christmas! One of the main features of FrankenPHP is its worker mode, which lets you keep a PHP application in memory to handle multiple HTTP requests. Worker modes are becoming increasingly popular in the PHP world. Symfony (Runtime Component), Laravel (Octane), and many