首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >流明制作:命令

流明制作:命令
EN

Stack Overflow用户
提问于 2015-05-15 11:30:16
回答 2查看 36.5K关注 0票数 31

我正在尝试通过命令行在Lumen安装中执行代码。在完整的Laravel中,我读到你可以通过"make: command“使用命令来实现这一点,但是Lumen似乎不支持这个命令。

有什么方法可以激活这个命令吗?如果失败了,在Lumen中从CLI运行代码的最佳方式是什么?

谢谢

EN

回答 2

Stack Overflow用户

发布于 2018-10-08 02:31:03

这是一个新命令的模板。您只需将其复制并粘贴到新文件中,即可开始工作。我在流明5.7.0上测试了它

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class CommandName extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'commandSignature';

    /**
     * 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()
    {

        $this->info('hello world.');
    }
}

然后在Kernel.php文件中注册它。

/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
   \App\Console\Commands\CommandName::class
];
票数 14
EN

Stack Overflow用户

发布于 2015-11-23 19:39:58

在创建命令类时,请使用以下命令:

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;

而不是上面描述的使用serve command示例

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30251065

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档