0

I am trying to run python files in Laravel Project.Therefore, i use the Symfony\Process package.My code looks like this:

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

$process = new Process(["python","C:\xampp\htdocs\backend\Scrape\AnnouncementsScrape.py"]);
$process->run();

When i use this line:

throw new ProcessFailedException($process);

my laravel project returns error (I use laravel framework for my backend in my mobile app, so i can not see the exactly error; i can only see that there is problem with my backend)

Το sum up, i run the code above, but the Process is not successfull. I check it with the condition:

if ($process->isSuccessful())

Anyone any idea?

Vagtse
  • 121
  • 1
  • 15

1 Answers1

0

Although the process may not be successful, it still produces an output, which you can access.

You can use $process->getOutput() and $process->getErrorOutput() for that

guillaumesmo
  • 545
  • 5
  • 8