PHP知识

laravel 如何自定义一个artisan命令

2018-10-30  本文已影响16人  _不能说的秘密i

laravel version: 5.5.*

php artisan  make:command  CustomCmd
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class CustomCmd extends Command
{
    /**
     * 定义命令的名称.
     *
     * @var string
     */
    protected $signature = 'custom:hello';

    /**
     * 定义命令的简单描述.
     *
     * @var string
     */
    protected $description = 'A Test Command';

    /**
     * 创建本命令对象
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 定义命令执行的内容
     *
     * @return mixed
     */
    public function handle()
    {
        echo 'hello world';
    }
}
protected $commands = [
    \App\Console\Commands::class,
];
show result
上一篇 下一篇

猜你喜欢

热点阅读