wordpress-playground icon indicating copy to clipboard operation
wordpress-playground copied to clipboard

Support requests to self (via an instance pool?)

Open adamziel opened this issue 10 months ago • 1 comments

Playground only runs a single PHP instance at the moment, which makes it impossible to request the following PHP file:

<?php
file_get_contents( get_site_url() . '/wp-admin/next.php' );

The file_get_contents() request gets issued before the current PHP file is served, meaning there's no PHP instance to handle that request. This is how this may be communicated in the devtools:

318657354-7e1c0472-1a8a-4c36-ab2e-1ad3e8cb8520

Perhaps a pool of 3-4 PHP instances would be enough to solve most of these errors. This would be consistent with what php-fpm does.

The only thing I'm worried about is the heap size – it's capped at 2GB at the moment, times 4 = 8GB. That's a lot of memory. I wonder if Playground could do away with, say, 256MB or 512MB memory limit.

Related issues

  • https://github.com/WordPress/wordpress-playground/issues/1177

Also, this issue is a pre-requisite for:

  • https://github.com/WordPress/wordpress-playground/issues/707

adamziel avatar Apr 02 '24 12:04 adamziel

Requests flow through PHPBrowser > PHPRequestHandler > PHP.

The PHPBrowser keeps track of cookies, and any cookies should apply to all the PHP instances in the pool.

The PHPRequestHandler represents a server in that it handles requests, URL rewriting, and stores config values like document root. It seems like it could accept an array of php objects instead of just a single one, and then round-robin between them.

adamziel avatar Apr 03 '24 11:04 adamziel