F
F
ff0xff2019-01-21 14:03:22
Laravel
ff0xff, 2019-01-21 14:03:22

Will laravel horizont execute class constructor on dispatch?

Good day, who worked with laravel horizont
I have in the class constructor that I dispatch-chu
There is an opening of the curl resource

public function __construct()
    {
        $this->curl = curl_init();

in __construct of the worker I pass the already created instance of the class
to handle () I call it like this The task is set in horizont but is executed with an error
$this->poster->login($this->accesses);
ErrorException: curl_setopt() expects parameter 1 to be resource, integer given in....
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'curl_setopt() e...', ' /var/www/html/w...', 177, Array)#1 script.php(177): curl_setopt(0, 10002, ' https://api-cab... ')

based on the error, I thought that the curl resource was not being created, thinking that horizont would serialize the object before handing it over to work.
i put it in wakeup()
public function __wakeup()
    {
        $this->curl = curl_init();

but it didn’t change anything, and if you call the class as usual, then everything works.
I suspect that something happens when transferring to horizont, but I can’t understand what’s the matter, who will tell me where to dig on this issue?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question