Hi and thanks for the latest great features.
Idea visualized: https://drive.google.com/file/d/1twuCTk2ssNl5damTydP-aOmOeJ5hWr9r/view?usp=sharing This is an idea and it's simple on the paper: *To run the requests coming to PHP Frameworks in three phases. * Let's say FPM pool child processes can run PHP instances in two-phase: - Initialization Phase: It runs an instance of our PHP code with no request information given. The running PHP code is interrupted by some kind of input mechanism which is put deliberately by the developer into the code. FPM will keep this process on RAM waiting for a request to come in. - *Waiting Phase* - Running Phase: There are a bunch of code instances in the waiting phase, one of them should be given the request to handle and respond back. Now this will give us the ability to write codes or frameworks that run faster. Let’s say that Laravel (any PHP project or framework) works like this: - It loads all its dependencies, providers, routes, configs and creates a connection to the database and the cache systems and any other have-to-run things which are necessary to handle a request - Then it waits for the request by simply putting something like a “fgets(STDIN)” *( any mechanism proposed by FPM )* - When input/request is given in some format, it continues running, handles the request, and responds back With this approach, we can remove the part of the time that PHP spends on Initializing frameworks for every single request and improve response times. I think that having *Opcache + Preloading Files + This Proposal* can significantly improve frameworks response times. The benefit of this approach over Ratchet, Fiber, or other RealTime works, is that it doesn't depend on PHP's memory handling problems so that can be used in production with more confidence. Please let me hear your feedback, thanks. Best wishes, Mohammad Eftekhari