简体   繁体   English

如何在 Laravel 上的队列作业中运行 Symfony Process 函数

[英]How to run Symfony Process function inside queue jobs on laravel

Now i'm doing some project use laravel framework.现在我正在做一些项目使用 Laravel 框架。 do i able to run Symfony Process function inside a queue jobs?我可以在队列作业中运行 Symfony Process 函数吗?

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

right now i want to run some commend using Symfony Process function for this现在我想为此使用 Symfony Process 功能运行一些推荐

process = new Process("facebook-scraper --filename public/data/nintendo.csv --pages 5 nintendo");

if outside the queue.如果在队列之外。 this code can run succesful.这段代码可以成功运行。 but when i want to make it run inside the queue jobs.但是当我想让它在队列作业中运行时。 it can't.它不能。

how do i able to run symfony Process function inside queue on jobs laravel.我如何能够在工作 laravel 的队列中运行 symfony Process 函数。

I think the problem is the paths.我认为问题是路径。 Replace the --filename option value with the absolute path (from /):--filename选项值替换为绝对路径(来自 /):

$path = public_path('data/nintendo.csv');

$process = new Process("facebook-scraper --filename {$path} --pages 5 nintendo");

...

... ...

And try to use full path to executable ( facebook-scraper ).并尝试使用可执行文件的完整路径( facebook-scraper )。 You can use which to find it.您可以使用which来查找它。

Example:例子:

$ which facebook-scraper       
/usr/bin/facebook-scraper

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM