ThePHPF / pie-design

108 stars 4 forks source link

Future scope: compile/install shared objects into a folder within a PHP project #5

Open Girgias opened 9 months ago

Girgias commented 9 months ago

As discussed with @asgrim at PHP UK 2024.

The idea would be to install the shared object resulting from the compilation of the extension into a folder within the PHP project. This would be similar to the /vendor/ folder composer creates and uses for dependencies.

The motivation for this is to allow different version of an extension to be installed for different projects, as those might not all be compatible with newer versions of a given extension.

What is probably needed is a generated INI file that is passed to PHP to load the .so at startup.

asgrim commented 9 months ago

I'm a big fan of this idea; however, thinking a bit more this, I think the unknown for me is how we can scope loading the shared object depending on the project. In something like a Dockerfile, there's less of an issue (since you'd usually scope your Dockerfile to an individual project and its specific requirements), but that's a small subset of applications, I'd guess.

I think off my head it is possible for PHP modules to be loaded per project (e.g. have a .user.ini) but this doesn't always work (I think in FPM mode, for example).

The other thing to consider with this, is even if we were to scope it per project, would there be an effect on performance; since extensions can take advantage of MINIT/MSHUTDOWN to avoid doing loading/unloading of things on every request, or having cross-request persistence and so on; it would essentially make every single request sequence MINIT,RINIT,RSHUTDOWN,MSHUTDOWN, which doesn't feel very efficient.