I want to start a lampp (php) webserver for another directory and I want to do it using Process class in Laravel. Below is my code of a controller method.
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
public function startServer(){
$process = new Process('cd /opt/lampp/htdocs/Project/ && sudo /opt/lampp/bin/php -S localhost:1000');
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
}
Now when I click on the button and call this method from the routing engine. It does start the webserver, but the page keeps processing the request until the timeout error occurs. Now I know for a fact that the server get started as soon as I click the button and the method is called because I check the localhost:1000 in the new browser tab and it's loading what it should be. So how can I stop the page loading and notify the user that the server is available? Because unless the output is shown it's hard to move ahead and work further in the same method. I've tried increasing the timeout limit but it still doesn't work that way.
Thanks in advance.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire