I found that pthreads
does not work on web environment. I use PHP7.1 on FPM on Linux Debian which i also use Symfony 3.2
. All I want to do is, for example:
- User made a request and
PUT
a file (which is 1GB) - PHP Server receives the file and process it.
- Immediately return
true
to user (jsonResponse
) without awaiting processing uploaded file - Later, when processing file is finished (move, copy, duplicate whatever you want) just add an event or do callback from background and notify user.
Now. For this I created Console Command
. I execute a Process('bin/console my:command')->start();
from background and I do my processing. But this is killing a fly with bazooka for me. I have to pass many variables to this executable command.
All I want to is creating another thread and just return to user without awaiting processing.
You may say this is duplicate. And point to pthreads
. But pthreads stated that it is only intended for CLI. Also last version of pthreads doesn't work with symfony. (fatal error).
I am stuck at this point and have doubt if should I stay with creating processes for each uploaded file or move to python -> django