2017-12-07 10 views
0

私はlaravel 5.5を使用していて、新しいコマンドを作成しようとしています。これは5.4でうまくいきましたが、今では全く登録されません。Laravelは新しいコマンドを登録していません

まず私は、コマンドを作成:

php artisan make:command heloworl 

をそして、私はこのような何かを得る:

<?php 

namespace App\Console\Commands; 

use Illuminate\Console\Command; 

class heloworl extends Command 
{ 
    /** 
    * The name and signature of the console command. 
    * 
    * @var string 
    */ 
    protected $signature = 'Hello:World'; 

    /** 
    * The console command description. 
    * 
    * @var string 
    */ 
    protected $description = 'Command description'; 

    /** 
    * Create a new command instance. 
    * 
    * @return void 
    */ 
    public function __construct() 
    { 
     parent::__construct(); 
    } 

    /** 
    * Execute the console command. 
    * 
    * @return mixed 
    */ 
    public function handle() 
    { 
     echo "hello world"; 
    } 
} 

は、今私は php artisan hello:worldを試してみて、それが、コマンドが全く存在しないことを言います。

また、私はコマンドのリストを得るためにちょうどphp artisanを試しましたが、そこにはありません。

アイデア?

答えて

1

app\Console\Kernel.phpprotected $commandsアレイに追加する必要があります。

class Kernel extends ConsoleKernel 
{ 

    /** 
    * The Artisan commands provided by your application. 
    * 
    * @var array 
    */ 
    protected $commands 
     = [ 
     //fully qualified namespace to class goes here 
     ]; 

} 
+0

私はLaravelがこれを自動的に行わないとは思いません。 – prgrm

+1

正しい場所にある場合、** 5.5 **に自動的にロードされます。 – lagbox

+0

@prgrm [ああ、でもできます](http://sergeyzhuk.me/2016/08/17/laravel-console-commands/ )。しかし、これはすでにLaravel 5.5 – Ohgodwhy

関連する問題