Hie*_* Le 40
您可以artisan像在Laravel中一样使用Lumen中的CLI,但使用较少的内置命令.要查看所有内置命令,请使用php artisanLumen中的命令.
虽然make:commandLumen 没有命令,但您可以创建自定义命令:
在app/Console/Commands文件夹中添加新的命令类,可以使用framework 命令的示例类模板serve
通过将创建的类添加到文件$commands内的成员来注册自定义命令app/Console/Kernel.php.
除了命令生成之外,您还可以在使用Lumen时使用Laravel docs命令.
小智 7
这是新命令的模板。您可以将其复制并粘贴到新文件中并开始工作。我在流明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.');
}
}
Run Code Online (Sandbox Code Playgroud)
然后将其注册在Kernel.php文件中。
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\CommandName::class
];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22721 次 |
| 最近记录: |