Performing asynchronous php requests from within a script + don't wait for responses

Hey :slight_smile:

t.php has been executed as expected :slight_smile: What’s the next step?

Once again, thanks to you all for your patience and help.


execInBackground('C:\\php\\php-win.exe C:\\ws\\htdocs\	.php');
$file = 'C:\\ws\\htdocs\\bar.txt';
$end = time() + 5;
// should output increasing numbers if other script still running
while (time() < $end) {
    echo filemtime($file) . "\
";
    sleep(1);
}


<?php
//t.php
$file = 'C:\\ws\\htdocs\\bar.txt';
$end = time() + 5;
while (time() < $end) {
    touch($file);
    sleep(1);
}

Whohou! :tup:

Is there a way to easily find these paths, for portability reasons :slight_smile:

I mean, when you switch servers. :slight_smile:

Often, instead of supplying the full path to the php executable like C:\php\php-win.exe you can just put php. The operating system will know what it means so long as there is a proper entry in the operating systems PATH environment variable. (If you’re running this on your local windows box, you probably don’t have this set in the env var unless you went and did it yourself.)

I think you should stick to supplying full php script paths though unless you understand well how current working directorys work, and how the behavior can vary between php run through the CLI. But abbreviating the path to the php executable binary as php will work very often on webservers you encounter.

If php doesn’t work, would it be a good approach to use put_env() in a config file to set it, so I just have to change the path here?

:slight_smile:

I wouldn’t use putenv(), but you could store a variable or constant.

:tup:

and rep++

:slight_smile: