2017-09-03 14 views
0

私はコントローラでカスタムアーティザンコマンドを実行しようとしていますが、例外はCommandNotFound例外をスローします。実装では、コマンド 'php artisan scan {url}'を実行する代わりに、コマンドを実行します。この回答のために、{url}スキャンを実行します。Running Artisan Command私は何を間違えたのか分かりません。コントローラでカスタムアーティザンコマンドを呼び出す| Laravel

カスタム職人コマンド署名

protected $signature = 'scan {url} 
          {--r= : y or n | to follow or not to follow the robot.txt} 
          {--fm= : set follow mode} 
          {--u= : username} 
          {--p= : password} 
          {--s : SQL module} 
          {--x : XSS module}'; 

実装

switch ($select) { 

    case 'full': 

    \Artisan::call('scan ' . $customer->cms_url); //url == http://localhost:8888 
    return $request; 

    break; 
} 

エラー

1/1) CommandNotFoundException 
There are no commands defined in the "scan http" namespace. 
in Application.php (line 548) 
at Application->findNamespace('scan http') 
in Application.php (line 582) 
at Application->find('scan http://localhost:8888') 
in Application.php (line 205) 

答えて

1

まず、コマンドでapp/console/Kernel.phpにArtisanコマンドを登録します。Arrayコマンドをクラスに追加します。その後、あなたの返事をいただきありがとうございます。この

\Artisan::call('scan',[ 'url' => "{$customer->cms_url}" ]); // You must wrap the url in " " otherwise it will not set the full string

+0

のようなあなたのコマンドを呼び出すことができます。これは正しい解決策です。 – melkawakibi

関連する問題