Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

atlas98's avatar

Problem with Stopping the php artisan serve command

hello , after stopping the server I will receive this error , please help me to solve the problem

2023-09-30 12:48:29 ErrorException

Undefined array key 1

at vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:312 308▕ $line = str_replace(' ', ' ', $line); 309▕ 310▕ preg_match($regex, $line, $matches); 311▕ ➜ 312▕ return Carbon::createFromFormat('D M d H:i:s Y', $matches[1]); 313▕ } 314▕ 315▕ /** 316▕ * Get the request port from the given PHP server output.

1 vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:312 Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap{closure}("Undefined array key 1", "D:\wamp64\www\FilamentProject\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php")

2 vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:277 Illuminate\Foundation\Console\ServeCommand::getDateFromLine("p 30 12:48:29 2023] 127.0.0.1:63334 Closing")

0 likes
6 replies
tisuchi's avatar

@atlas98 I think the quick fix will be to avoid displaying the log in the console.

php artisan serve --no-reload

The --no-reload flag will prevent artisan serve from displaying logs, and as such, you won't experience this error.

⚠️ It is just a workaround.

atlas98's avatar

@tisuchi

Unfortunately it doesn't work

when more than 5 request in less time will send to server this error will happen again

I read an article somewhere else , it described that this is because of the format of the date values because it doesn't have second parameter at the end of the string and this differences will happen error

I don't know is this correct or not but his solution didn't work for me as well

tisuchi's avatar

@atlas98 Then there might be fixes available in newer versions of Laravel. Run:

composer update

Or

  • Delete vendor folder and run:
composer install
atlas98's avatar

@tisuchi

my laravel version is the latest I did your solution but the issue doesn't fix I removed Vendor folder and run composer install. I use Wamp 3.3 - 64 bit for webserver it installs 4 version of PHP 7.4.33/8.0.26/8.1.13/8.2.0 is it possible this problem will happen because of the selected version of PHP ? I installed Laravel ==> "laravel/framework": "^10.10",

tisuchi's avatar

@atlas98 I don't think it's a problem!

If you download a laravel project with composer create-project .... and you get laravel/framework 10x, surely your php version is at least 8.1.

atlas98's avatar

@tisuchi yes I installed Laravel with composer create-project .... , in CMD if I check the version of php that is 8.2 but in wamp server between 4 versions I can switch , at the moment in wamp server I am selecting 8.2 version but problem still remaining

Please or to participate in this conversation.