1. 创建自定义 artisan 命令
php artisan make:command SwooleManger // 默认在 app/Console/Commans 目录下创建 SwooleManger.php 文件。
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\App;
class SwooleManger extends Command
{
private $server;
private $pid_file;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'swoole {action}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'start or stop the swoole process';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
$this->pid_file = __DIR__.'/