【问题标题】:Laravel console command not workingLaravel 控制台命令不起作用
【发布时间】:2016-09-25 20:27:41
【问题描述】:

尝试在 laravel 5.2 上设置示例控制台命令,但它不起作用

我跑了php artisan make:console CoolCommand

这是我的文件

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

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

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Allows you to be cool';

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

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        echo "Yes you are very cool!";
    }
}

当我点击 php artisan 时,该命令未在给定签名下列出

我错过了什么? 谢谢

【问题讨论】:

标签: php laravel console


【解决方案1】:

如果在您键入php artisan 时未列出该命令,则您忘记按照here 的说明注册该命令。打开app/Console/Kernel.php 并输入您的命令。

 protected $commands = [
     Commands\CoolCommand::class
 ];

【讨论】:

    猜你喜欢
    • 2015-10-16
    • 1970-01-01
    • 2015-01-31
    • 2017-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-12
    • 1970-01-01
    相关资源
    最近更新 更多