lumen要想像laravel一样运行 php artisan serve 来启动本地运行服务可以添加以下Artisan命令

    1. <?php
    2. namespace App\Console\Commands;
    3. use Illuminate\Console\Command;
    4. class Serve extends Command
    5. {
    6. /**
    7. * 命令名称及签名
    8. *
    9. * @var string
    10. */
    11. protected $signature = 'serve';
    12. /**
    13. * 命令描述
    14. *
    15. * @var string
    16. */
    17. protected $description = '本地 server 启动命令';
    18. /**
    19. * 创建命令
    20. *
    21. * @return void
    22. */
    23. public function __construct()
    24. {
    25. parent::__construct();
    26. }
    27. /**
    28. * 执行命令
    29. *
    30. * @return mixed
    31. */
    32. public function handle()
    33. {
    34. shell_exec("php -S localhost:8000 -t public");
    35. }
    36. }