php - Thread with Laravel - Model class not found when calling start() -


i using laravel 5.1 , trying start several threads within command class:

$documents->chunk(1000, function($documentchunk) use (&$threads, &$threadnumber, &$repository) {     $threads[$threadnumber] = new mythread($documentchunk);     $threads[$threadnumber]->start();     $this->info("thread [".$threadnumber."] running");     $threadnumber++; }); 

the $documents variable has been filled data retrieved database

in mythread class have:

<?php namespace app\helpers;  use download;  class mythreadextends \thread {      protected $chunk;      public function __construct($chunk) {         $this->chunk = $chunk;     }      public function run() {         ...         $downloads = download::select(...);         ...     }  } 

on select line, a:

php fatal error: class 'download' not found

however, if call directly $threads[$threadnumber]->run() instead of $threads[$threadnumber]->start(), not have error. maybe problem of class loading can't figure out what's real problem , if can solved...

if me this, grateful since it's been hours i'm on problem.

thanks, killian.

you need setup autoloader, help here

i think example symfony, same thing applies.


Comments