Reputation: 383
I have searched extensively to solve the issue of opening an external program in phpdesktop without PHP waiting ultimately making PHP timeout.
I need to be able to launch the program with exec()
and have the rest of the PHP code execute without waiting on the exec()
command. I have tried multiple solutions. To make matters even more complicated the file that is being opened is on a networked drive. Here is what I have tried but has not worked
pclose(popen('start' .$File. '>NUL 2>NUL"', 'r')); This didn't work because the drive is on the network
exec($File); Doesn't work as it waits instead of executing the remainder of the code
system($File); Doesn't work. Same result as exec()
exec($File > /dev/null); Obviously doesnt work because php is on windows
The file being executed is a video file: mp4
, avi
or mkv
. So it's opening the external video player file but like I said above PHP ultimately times out and gives an error after 30 seconds without executing the rest of the code. I just need PHP to ignore the program it opened and go on about its tasks. Any help would be greatly appreciated.
Upvotes: 1
Views: 390
Reputation: 315
You could use something like "nircmd" which is a windows command-line utility to perform tasks and is a perfect fit for php-desktop. You can use the variety of "exec" actions "nircmd" has, so you could call whatever you want and immediately return to php. See the manual (.chm archive), under windows 7/10 you might have to "unblock" that help file (at file properties), to view the contents.
Upvotes: 1
Reputation: 2219
If 'phpdesktop' uses the built in web server in php (php -S) then it is as far as I know not possible to do so without having the exec call blocking, same with proc_open etc
I looked it up and indeed phpdesktop uses the builtin web server: https://github.com/cztomczak/phpdesktop/blob/c00988f69348b73b6dee27bdf45d145b719e2a3d/phpdesktop-chrome/php_server.cpp
In theory proc_open should work, but it doesn't
Upvotes: 0