make:命令在Laravel 5.1.7中没有定义


make:command not defined in Laravel 5.1.7

我试图使用make:console来创建一个调度器,但是它返回:

  [InvalidArgumentException]              
  Command "make:console" is not defined. 
  Did you mean one of these?       
     make:seeder                         
     make:migration   

如果这是在5.0版本之前,那就足够了,但我目前使用的是5.1.7。什么会导致这个问题?

下面是当前可用命令的列表:

  help                Displays help for a command
  list                Lists commands
  migrate             Run the database migrations
  serve               Serve the application on the PHP development server
 cache
  cache:clear         Flush the application cache
  cache:table         Create a migration for the cache database table
 db
  db:seed             Seed the database with records
 make
  make:migration      Create a new migration file
  make:seeder         Create a new seeder class
 migrate
  migrate:install     Create the migration repository
  migrate:refresh     Reset and re-run all migrations
  migrate:reset       Rollback all database migrations
  migrate:rollback    Rollback the last database migration
  migrate:status      Show the status of each migration
 queue
  queue:failed        List all of the failed queue jobs
  queue:failed-table  Create a migration for the failed queue jobs database table
  queue:flush         Flush all of the failed queue jobs
  queue:forget        Delete a failed queue job
  queue:listen        Listen to a given queue
  queue:restart       Restart queue worker daemons after their current job
  queue:retry         Retry a failed queue job
  queue:subscribe     Subscribe a URL to an Iron.io push queue
  queue:table         Create a migration for the queue jobs database table
  queue:work          Process the next job on a queue
 schedule
  schedule:run        Run the scheduled commands

如果我将composer.json修改为5.2版本。*我收到一个更精简的命令选择:

  help              Displays help for a command
  list              Lists commands
  migrate           Run the database migrations
 cache
  cache:clear       Flush the application cache
 db
  db:seed           Seed the database with records
 make
  make:migration    Create a new migration file
 migrate
  migrate:install   Create the migration repository
  migrate:refresh   Reset and re-run all migrations
  migrate:reset     Rollback all database migrations
  migrate:rollback  Rollback the last database migration
  migrate:status    Show the status of each migration
 queue
  queue:failed      List all of the failed queue jobs
  queue:flush       Flush all of the failed queue jobs
  queue:forget      Delete a failed queue job
  queue:listen      Listen to a given queue
  queue:restart     Restart queue worker daemons after their current job
  queue:retry       Retry a failed queue job
  queue:work        Process the next job on a queue
 schedule
  schedule:run      Run the scheduled commands

我找到了一个解决方法。即使我的Laravel CLI缺少前面提到的命令,我仍然有调度和命令文件结构可以操作。

Commands目录下手动创建example_scheduled_command.php,注册到Kernal.php。然后你可以使用Laravel调度

我有同样的问题,但我可以使用

解决它
php artisan make:console AssignUsers --command=users:assign

然后在app/Console/Kernel.php

中注册命令

见:https://laravel.com/docs/5.0/commands

Try

php artisan make:command nameCommand

运行它:

我不知道为什么,但我有同样的问题"schedule:work"我通过手动将其添加到app/console/kernel.php

来解决它
protected $commands = [
    Illuminate'Console'Scheduling'ScheduleWorkCommand::class
]

在照亮文件夹中有很多可用的命令,但是没有显示在"工匠列表"