0
votes

I'm trying to implement consolibyte/quickbooks-php in my Laravel 6 project. It works fine if I call the Queue action from a controller. But now I want to do it async with a Laravel job. That is where I'm getting the error :

I receive this error:

 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')

This specific line it is referring to is here in Loader.php:

if (QUICKBOOKS_LOADER_REQUIREONCE)
{
    require_once QUICKBOOKS_BASEDIR . $file;
}

I logged QUICKBOOKS_BASEDIR . $file and the path it makes is correct and the file is present there. Permissions are valid too.

Job:
class AddInventoryIntoQB implements ShouldQueue { use 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);
}

It only works if i don't run it as a Job. What am i doing wrong?

1

1 Answers

1
votes

The most likely cause of this error:

QuickBooks_Loader::load(): Failed opening required '/var/www/html/buyforme/b4m-aportal-v2/vendor/consolibyte/quickbooks/QuickBooks/Driver/.php'

Is a malformed or empty dsn connection string. That is, the code is looking for a database driver, and the database driver you specified to use doesn't exist.

In this code:

public function __construct()
{
    $this->config = config('quickbooks');

    $this->dsn    = $this->config['qb_dsn'];
}

Are you:

  • are you 100% sure that qb_dsn is even set to a value?
  • are you 100% sure it's set to a valid DSN database connection string?
  • are any characters in the string that need to be URL encoded, actually URL encoded properly?

Can you paste your dsn string (with the password masked/removed)?