【发布时间】:2023-12-25 04:35:01
【问题描述】:
我正在尝试在我的 Laravel 6 项目中实现 conolibyte/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);
}
仅当我不将其作为作业运行时才有效。我做错了什么?
【问题讨论】:
标签: laravel quickbooks laravel-6.2