dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.7k stars 220 forks source link

gmp and imagick and other extensions not loaded #623

Closed Issa-projects closed 6 months ago

Issa-projects commented 6 months ago

What happened?

I am encountering an issue with Laravel Octane in conjunction with FrankenPHP. While my Laravel application is generally functioning well, I recently installed Imagick and GMP extensions on my Ubuntu 22.04 server using apt install php8.3-extension_name. The installation was successful, confirmed by running php -m, which displayed the newly installed extensions.

However, Laravel Octane continues to raise complaints about these extensions being absent.

Steps to Reproduce:

Installed Imagick and GMP extensions on Ubuntu 22.04 server. Confirmed successful installation via php -m. Created a PHP file to print loaded extensions. Executed the file from the Laravel project root using ./frankenphp php-cli file.php. The output revealed that Imagick and GMP extensions were missing, despite being installed. Expected Behavior:

Laravel Octane should recognize and acknowledge the presence of the installed Imagick and GMP extensions.

Actual Behavior:

Laravel Octane insists that Imagick and GMP extensions are not installed, despite evidence of successful installation.

Additional Information:

Laravel version: 10.46 PHP version: 8.3 FrankenPHP version: 1.1.0 Server OS: Ubuntu 22.04 This bug report aims to bring attention to the discrepancy between the successful installation of extensions and Octane's failure to recognize them. Any assistance in resolving this matter would be greatly appreciated.

Build Type

Laravel octane installation

Worker Mode

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

System  Linux ab1486b3f8a2 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64
Build Date  Feb 18 2024 00:38:32
Build System    Linux buildkitsandbox 6.2.0-1019-azure #19~22.04.1-Ubuntu SMP Wed Jan 10 22:57:03 UTC 2024 x86_64 Linux
Configure Command   './configure' '--prefix=' '--with-valgrind=no' '--enable-shared=no' '--enable-static=yes' '--disable-all' '--disable-cgi' '--disable-phpdbg' '--disable-cli' '--disable-fpm' '--enable-embed=static' '--disable-micro' '--disable-opcache-jit' '--enable-zts' '--disable-zend-signals' '--enable-zend-max-execution-timers' '--enable-apcu' '--enable-bcmath' '--with-bz2=/go/src/app/dist/static-php-cli/buildroot' '--enable-calendar' '--enable-ctype' '--with-curl' '--enable-dba' '--enable-dom' '--enable-exif' '--enable-fileinfo' '--enable-filter' '--with-zlib' '--with-zlib-dir=/go/src/app/dist/static-php-cli/buildroot' '--enable-gd' '--with-freetype' '--with-jpeg' '--with-webp' '--with-avif' '--with-iconv=/go/src/app/dist/static-php-cli/buildroot' '--enable-igbinary' '--enable-intl' '--with-openssl=/go/src/app/dist/static-php-cli/buildroot' '--with-openssl-dir=/go/src/app/dist/static-php-cli/buildroot' '--with-ldap=/go/src/app/dist/static-php-cli/buildroot' '--enable-mbstring' '--enable-mysqlnd' '--with-mysqli' '--enable-opcache' '--enable-pcntl' '--enable-pdo' '--with-pdo-mysql' '--with-pgsql=/go/src/app/dist/static-php-cli/buildroot' '--with-pdo-pgsql=/go/src/app/dist/static-php-cli/buildroot' '--with-sqlite3=/go/src/app/dist/static-php-cli/buildroot' '--with-pdo-sqlite' '--enable-phar' '--enable-posix' '--with-readline=/go/src/app/dist/static-php-cli/buildroot' '--enable-session' '--enable-redis' '--enable-redis-session' '--enable-redis-igbinary' '--enable-redis-lz4' '--with-liblz4=/go/src/app/dist/static-php-cli/buildroot' '--enable-simplexml' '--enable-sockets' '--with-sodium' '--enable-sysvsem' '--enable-tokenizer' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-libxml=/go/src/app/dist/static-php-cli/buildroot' '--with-zip=/go/src/app/dist/static-php-cli/buildroot' 'CFLAGS=' 'PKG_CONFIG=/go/src/app/dist/static-php-cli/buildroot/bin/pkg-config' 'PKG_CONFIG_PATH=/go/src/app/dist/static-php-cli/buildroot/lib/pkgconfig'
Server API  FrankenPHP
Virtual Directory Support   enabled
Configuration File (php.ini) Path   /lib
Loaded Configuration File   (none)
Scan this dir for additional .ini files (none)
Additional .ini files parsed    (none)
PHP API 20230831
PHP Extension   20230831
Zend Extension  420230831
Zend Extension Build    API420230831,TS
PHP Extension Build API20230831,TS
Debug Build no
Thread Safety   enabled
Thread API  POSIX Threads
Zend Signal Handling    disabled
Zend Memory Manager enabled
Zend Multibyte Support  provided by mbstring
Zend Max Execution Timers   enabled
IPv6 Support    enabled
DTrace Support  disabled
Registered PHP Streams  https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3
Registered Stream Filters   zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, convert.*, consumed, dechunk

Relevant log output

No response

Issa-projects commented 6 months ago

Anyone?

dunglas commented 6 months ago

Static builds of FrankenPHP can only use bundled extensions. Installing extra extensions using the OS package manager will not work, FrankenPHP will not be able to use them.

If you want to add extra extensions (or remove other extensions), you have to create a custom build: https://frankenphp.dev/docs/static/#custom-extensions

Another option (recommended), is to use the Docker images to install custom extensions: https://frankenphp.dev/docs/docker/#how-to-install-more-php-extensions

Issa-projects commented 6 months ago

I will try that, thank you

Issa-projects commented 6 months ago

@dunglas i couldn't manage to create frankenphp executable (like the one laravel octane creates) with the imagick and gmp extension. Can you please give me example docker file? I would really appreciate it

SebastianSchoeps commented 4 months ago

@Issa-projects Any news on that? I run into the same issue. It basically means that e.g. the popular Laravel package https://github.com/spatie/laravel-medialibrary is not working out of the box with FrankenPHP on Forge. Will have to go back to Roadrunner.

Issa-projects commented 4 months ago

@SebastianSchoeps no, i could not figure it out. Please let me know if you find a solution. I have an open issue here https://github.com/dunglas/frankenphp/issues/664

Issa-projects commented 4 months ago

@SebastianSchoeps i tried this aproach, but it is not working when i include gd:

git clone https://github.com/dunglas/frankenphp
cd frankenphp
docker buildx bake --load --set "*.platform=linux/amd64" --set static-builder.args.PHP_EXTENSIONS=bcmath,ctype,curl,dom,fileinfo,filter,gd,intl,gmp,iconv,imagick,mbstring,mysqli,mysqlnd,openssl,pdo,pdo_mysql,session,simplexml,ssh2,token
izer,xml,zlib static-builder
SebastianSchoeps commented 4 months ago

@Issa-projects I switched back to Roadrunner - that works out of the box...

HelgeSverre commented 3 months ago

In case anyone is running into issues with Color Thief, this is the reason why it doesn't work when using frankenphp.