Level 3
exec('php '.public_path($order->filename).' > /dev/null 2>&1 &');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everybody. I tried to create some PHP script files in laravel public folder like this:
$filename = $orderID.'-'.time().'.php';
$newfile = fopen($filename, 'w');
$str = '...test...';
fwrite($newfile, $str);
fclose($newfile);
return $filename;
It creates the file successfully in Public folder. My first Question is how can i change the path for my script when creating it? My second problem is How to call it? when i called it from Laravel controller with:
exec('php '.$order->filename.' > /dev/null 2>&1 &');
it raise the "The system cannot find the path specified." error in terminal. Any help would be appreciated.
Please or to participate in this conversation.