Introducing a new PhpSubprocess handler #48485
Open
+280
∄1�70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
This PR provides a new
PhpSubprocess
handler which can be used to run PHP commands and taking over their parent PHP configuration. This is not super easy in PHP because the only way to do that requires a temporaryini
file.That's why I see perfect fit for it in the
symfony/process
component as it solves a common issue.The code is heavily inspired/copied from
composer/xdebug-handler
where the requirement is similar - being able to have a child process/subprocess that takes over the config of the parent process. Hence, mentioning @Seldaek here.Basically, this can be very useful in Symfony when you want to run
bin/console other-command
from within Symfony.Let's imagine a general cronjob command that is supposed to delegate to other commands like this (simplified a lot):
Now if you run the cronjob command itself with dynamic configuration like so:
php -d memory_limit=256M bin/console run-cronjobs
, the subprocesses (cache:pool:prune
etc.) will not be limited to256M
because they themselves will start a completely new PHP process which will take the default PHP settings again.This affects everything, not just
memory_limit
but also runtime, extensions etc. You name it.Oftentimes, however, that's not what you want. You'd like to have the children have the same restrictions as your parent process.
With this new handler, all you have to do is to use😊
PhpSubprocess
instead ofProcess
and it will create a temporaryini
file taking over all the settings of the parent process. DoneThe current design is pretty straightforward without any extension points just yet (no way to fetch the😊
ini
files separately etc.). Also, it could maybe do with some more tests for theini
parsing but at this stage I would like to ask if this would even be a welcomed addition to Symfony or not