-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Closed
Description
Laravel Version
10.17.0
PHP Version
8.2.9
Database Driver & Version
not relevant
Description
When using current Chrome or Fireox on Linux trying to access a Laravel installation served by php artisan serve
on localhost:9000
, during serving the first request, ServeCommand
fails in getDateFromLine
with a Carbon exception about an unexpected format.
The reason is that the date string seems to have two spaces between the month and day:
protected function getDateFromLine($line)
{
$regex = env('PHP_CLI_SERVER_WORKERS', 1) > 1
? '/^\[\d+]\s\[([a-zA-Z0-9: ]+)\]/'
: '/^\[([^\]]+)\]/';
preg_match($regex, $line, $matches);
dd($line, $matches);
return Carbon::createFromFormat('D M d H:i:s Y', $matches[1]);
}
"[Wed Aug 2 11:30:23 2023] 127.0.0.1:46238 Accepted" // vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php:309
array:2 [ // vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php:309
0 => "[Wed Aug 2 11:30:23 2023]"
1 => "Wed Aug 2 11:30:23 2023"
]
When changing the createFromFormat
argument to 'D M d H:i:s Y'
(note the two spaces) it works perfectly fine.
I just upgraded PHP from 8.2.8 to 8.2.9, and it started after that, so that's potentially related.
Steps To Reproduce
- Use Linux (not sure if that's a requirement, maybe it's also broken on other platforms?)
- Install PHP 8.2.9
laravel new foo
cd foo
php artisan serve
- Navigate to
http://localhost:8000
- Check command line output, notice an exception:
Carbon\Exceptions\InvalidFormatException
Unexpected data found.
at vendor/nesbot/carbon/src/Carbon/Traits/Creator.php:687
...
camilledtr, Stenfrank, pedestrianlove and davisenra
Metadata
Metadata
Assignees
Labels
No labels