laravel / installer

The Laravel application installer.
https://laravel.com/docs
MIT License
683 stars 292 forks source link

Laravel installer fails on PHP 8.3 using Windows WSL #384

Closed JasonTame closed 1 week ago

JasonTame commented 1 week ago

Installer Version

5.11.1

Description

Attempting to run laravel new on WSL when using PHP 8.3 leads to the following error:

PHP Fatal error:  Uncaught Error: Call to undefined function Laravel\Installer\Console\mb_rtrim() in /home/jaytame/.config/composer/vendor/laravel/installer/src/NewCommand.php:162

I have tested on MacOS and it works fine on PHP 8.3 there, it seems like mb_trim gets polyfilled on Mac.

Steps To Reproduce

peter279k commented 1 week ago

The mb_rtrim is available when enabling mbstring extension.

If using the Ubuntu WSL distribution, it needs to install this extension via the sudo apt-get install php-mbstring command.

We can see that the mbstring extension is enabled when running the tests in the GitHub workflow.

JasonTame commented 1 week ago

Hi @peter279k

I have mbstring enabled on PHP 8.3, here's the output of php -m:

jaytame@jmtwinlaptop:~$ php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
random
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Even so, I get the undefined function error when running laravel new. Also, I'm pretty sure the installer would immediately fail if I didn't have mbstring as it is a required extension in the ensureExtensionsAreAvailable() method.

Changing to PHP 8.4 resolves this issue and the installer works as normal.

peter279k commented 1 week ago

mb_rtrim is only available since the 8.4 version is released.