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
相关产品推荐
相关产品推荐

