You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel执行php artisan serve启动服务器时出现Undefined array key 1报错

Laravel php artisan serve 启动报错:Undefined array key 1

按照Laravel文档中的命令安装了Composer、PHP和Laravel:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows'))

创建新应用的过程正常,但执行php artisan serve命令时,服务器启动后立即抛出错误并自行关闭,错误信息如下:

Undefined array key 1

  at vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:368
    364▕         $line = str_replace('  ', ' ', $line);
    365▕
    366▕         preg_match($regex, $line, $matches);
    367▕
  ➜ 368▕         return Carbon::createFromFormat('D M d H:i:s Y', $matches[1]);
    369▕     }
    370▕
    371▕     /**
    372▕      * Get the request port from the given PHP server output.

  1   vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:368

已查找相关问题线程,尝试以下方案均未解决问题:

  • php artisan config/cache/view:clear
  • 更新Composer
  • 更新Windows

当前环境版本:

  • PHP v8.3.11
  • Composer v2.8.1
  • Laravel v11.9

此前使用Laravel 9时未使用XAMPP,而多数教程采用XAMPP环境。

内容的提问来源于stack exchange,提问作者Arne Sneyers

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 03:22:41