2014-01-30 2 views
1

Bellow는 속도를 위해 pthreads를 사용하여 전자 메일 주소 존재를 확인하는 데 사용하는 스크립트입니다. 내가 Laravel 명령에 넣을 때 문제는 내가이 오류를 얻을 수 있습니다 :pthreads를 사용할 때 Laravel 명령에 오류가 발생합니다.

Fatal error: Call to undefined method Illuminate\Support\Facades\Log::error() in /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 208 

이것은 스크립트입니다

<?php 

      use Illuminate\Console\Command; 
      use Symfony\Component\Console\Input\InputOption; 
      use Symfony\Component\Console\Input\InputArgument; 



      class verifyLocal extends Command 
      { 

       protected $name = 'verify:local'; 
       protected $description = 'verify emails from local server'; 



       public function __construct() 
       { 
        parent::__construct(); 

       } 

       public function fire() 
       { 
        $start = microtime(true); 
        $emails = array(
         new WebRequest("[email protected]"), 
         new WebRequest("[email protected]") 
        ); 

        $threads = array(); 

        foreach ($emails as $k => $email) { 
         $req[$k] = new WebRequest($email); 
         $threads[$k] = new WebWorker(); 
         $threads[$k]->start(); 
         $threads[$k]->stack($req[$k]); 
        } 

        /* wait for completion */ 
        foreach ($threads as $thread) { 
         $thread->shutdown(); 
        } 

        foreach ($req as $r) { 
         var_dump($r); 
        } 

        $time = microtime(true) - $start; 
        printf("Fetched %d responses in %.3f seconds\n", count($req), $time); 

       } 

      } 




      class WebRequest extends Stackable { 
       public $email_address; 
       public $response_body; 

       public function __construct($email_address) { 
        $this->email_address = $email_address; 
       } 

       public function run(){ 
        $this->response_body = $this->check($this->email_address); 
       } 

       public function check($email) { 
        /* verification code here */ 
        $answer = true; 
        return $answer; 
       } 


      } 

      class WebWorker extends Worker { 
       public function __construct() { 

       } 
       public function run(){ 

       } 
      } 


      ?> 

어떤 도움을주세요. 감사.

내가 Laravel를 사용하지 않는

답변

2

, 내 생각 엔 당신이 laravel이 제대로 작동하도록 작업자/스레드의 실행 방법에 오토로더를 설치할 필요가있다 은 ... 먼저 시도

foreach ($emails as $k => $email) { 
    $req[$k] = new WebRequest($email); 
    $threads[$k] = new WebWorker(); 
    $threads[$k]->start(); 
    $threads[$k]->stack($req[$k]); 
} 

이것은 각 전자 메일에 대해 작업자를 만들고 싶다는 의미이며 실제로는 매우 낭비입니다.

+0

감사합니다. 나는 이것을 시도 할 것이다. – kpios

관련 문제