On Mon, Sep 5, 2016 at 1:47 PM, Andrea Faulds <a...@ajf.me> wrote: > Hi Michael, > > Have you looked into PHP application servers, where the PHP code itself > acts as the web (or FastCGI) server, and so can keep the whole framework > etc. initialised in memory between requests? >
I have - it's what I was referring to when I mentioned PHP worker process trickery. I know it can be done, but it isn't straightforward and it can't be quickly applied to existing applications like Wordpress or Drupal. > > This is how other (non-PHP) web stacks avoid “installing the application > on every single request”, and it can also be applied to PHP, it's just not > very common. > I know. What I'm wondering though is, could there be a way to do this on the PHP engine level that would avoid massive rewrites of existing PHP code. Here's my current draft of a way to implement this using two statements. require_bootstrap( [FILE] ); This statement loads and executes the code in question just as require does. It saves the execution state before moving to the next code line after this statement is called. If called without a file it saves the execution state immediately. The saved execution state is hostname aware for sites that use a multisite configuration. So if the statement is reached from www.onesite.com/index.php and from www.twosite.com/index.php two different bootstraps will be created. This is done on the assumption that the booting process is going to make one or more decisions based on the hostname. Drupal loads entirely different setting files, module lists, uses a different Dependency Injector, all according to the hostname. unload_bootstrap( [PATH] ); This unloads the bootstrap associated with the webpath given. If no argument is given the current bootstrap image is dropped. Question - should passing boolean TRUE unload all the bootstraps at once, or should that be it's own function, or is it necessary? Note that bootstraps will be unloaded automatically if the opcode cache for the associated files changes. Thoughts, suggestions, questions, complains, or flames?