我正在尝试在我的 Laravel 6 项目中实现 consolibyte/quickbooks-php。如果我从控制器调用队列操作,它工作正常。但现在我想用 Laravel 的工作来做异步。那就是我得到错误的地方:
我收到此错误:
QuickBooks_Loader::load(): Failed opening required '/var/www/html/buyforme/b4m-aportal-v2/vendor/consolibyte/quickbooks/QuickBooks/Driver/.php' (include_path='.:/usr/share/php:/var/www/html/buyforme/b4m-aportal-v2/vendor/consolibyte/quickbooks')
它所指的这一特定行在 Loader.php 中:
if (QUICKBOOKS_LOADER_REQUIREONCE)
{
require_once QUICKBOOKS_BASEDIR . $file;
}
我登录QUICKBOOKS_BASEDIR . $file
了,它创建的路径是正确的,并且文件在那里。权限也是有效的。
作业:
类 AddInventoryIntoQB 实现 ShouldQueue { 使用 Dispatchable、InteractsWithQueue、Queueable、SerializesModels;
/**
* Item object.
*/
protected $item;
/**
* @var LaravelQbd
*/
protected $QBD;
/**
* Create a new job instance.
*
* @param Item $item
*/
public function __construct(Item $item)
{
$this->QBD = new LaravelQbd;
$this->item = $item;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$this->QBD->enqueue(QUICKBOOKS_ADD_INVENTORYITEM, $this->item);
}
LaravelQbd:
/**
* User Configuration File Array
*/
protected $dsn;
protected $config;
protected $map = [];
public function __construct()
{
$this->config = config('quickbooks');
$this->dsn = $this->config['qb_dsn'];
}
public function enqueue($action, $object, $priority = 0, $extra = null, $user = null)
{
$Queue = new \QuickBooks_WebConnector_Queue($this->dsn);
return $Queue->enqueue($action, $object, $priority, $extra, $user);
}
它仅在我不将其作为作业运行时才有效。我究竟做错了什么?