Gam*_*7er 5 laravel laravel-artisan
我想做一个别名
php artisan go
代替
php artisan serve
我会很感激任何其他想法:-)。我也阅读了这个链接并搜索了很多,但不是很清楚,其他问题是关于制作class或.env文件等。
提前致谢
更新
这个问题是不能重复的这个,因为它不包含调用php artisan本身。
使用以下命令创建命令:
php artisan make:command GoCommand
Run Code Online (Sandbox Code Playgroud)
在类中添加:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Symfony\Component\Console\Output\ConsoleOutput;
class GoCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'go';
/**
* 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()
{
$output = new ConsoleOutput;
$output->writeln("Laravel development server started: <http://127.0.0.1:8000>");
Artisan::call('serve');
Artisan::output();
}
}
Run Code Online (Sandbox Code Playgroud)
使用命令:
php artisan go
Run Code Online (Sandbox Code Playgroud)
访问:http : //127.0.0.1 : 8000/
并查看控制台中的输出。
| 归档时间: |
|
| 查看次数: |
3075 次 |
| 最近记录: |