-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Exclude default extensions for PHP ^8.1 #8273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude default extensions for PHP ^8.1 #8273
Conversation
@@ -12,7 +12,6 @@ | |||
"require": { | |||
"php": "^8.1", | |||
"ext-intl": "*", | |||
"ext-json": "*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is part of the PHP core.
composer.json
Outdated
"ext-gd": "If you use Image class GDHandler", | ||
"ext-imagick": "If you use Image class ImageMagickHandler", | ||
"ext-libxml": "If you use TestResponse", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
This extension requires » libxml >= 2.9.0 as of PHP 8.0. libxml >= 2.6.0 prior to PHP 8.0.
https://www.php.net/manual/en/libxml.requirements.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true.
However PHP handles downstream dependencies for you. There is no need to check for the required libraries downstream.
If PHP states
The libxml extension is enabled by default,
https://www.php.net/manual/en/libxml.installation.php, that's all there is to check.
Let's dig deeper:
php=$(which php)
php_pkg=$(rpm -qf $php)
rpm -q "${php_pkg}" --requires
, or
rpm -q "${php_pkg}" --requires | grep -i xml
Finally:
(there is no package for libxml)
dnf search libxml | grep -i php
(included by default)
php -r "phpinfo();" | grep -i xml
Cannot check the same on Windows and others, but it should be similar.
So the remarks regarding http://www.xmlsoft.org/ do not apply unless there is a different approach from PHP on other operating systems. I'm using Fedora.
composer.json
Outdated
@@ -38,21 +37,16 @@ | |||
}, | |||
"suggest": { | |||
"ext-curl": "If you use CURLRequest class", | |||
"ext-dom": "If you use TestResponse", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
This extension requires the libxml PHP extension.
https://www.php.net/manual/en/dom.requirements.php
composer.json
Outdated
"ext-exif": "If you run Image class tests", | ||
"ext-fileinfo": "Improves mime type detection for files", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. not part of the PHP core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows exception. Okay.
composer.json
Outdated
"ext-memcache": "If you use Cache class MemcachedHandler with Memcache", | ||
"ext-memcached": "If you use Cache class MemcachedHandler with Memcached", | ||
"ext-mysqli": "If you use MySQL", | ||
"ext-oci8": "If you use Oracle Database", | ||
"ext-pgsql": "If you use PostgreSQL", | ||
"ext-readline": "Improves CLI::input() usability", | ||
"ext-redis": "If you use Cache class RedisHandler", | ||
"ext-simplexml": "If you format XML", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extension requires the libxml PHP extension.
composer.json
Outdated
"ext-memcache": "If you use Cache class MemcachedHandler with Memcache", | ||
"ext-memcached": "If you use Cache class MemcachedHandler with Memcached", | ||
"ext-mysqli": "If you use MySQL", | ||
"ext-oci8": "If you use Oracle Database", | ||
"ext-pgsql": "If you use PostgreSQL", | ||
"ext-readline": "Improves CLI::input() usability", | ||
"ext-redis": "If you use Cache class RedisHandler", | ||
"ext-simplexml": "If you format XML", | ||
"ext-sqlite3": "If you use SQLite3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be disabled.
https://www.php.net/manual/en/sqlite3.installation.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, so this goes for "Can be disabled" remarks.
The following:
This extension is enabled by default. It may be disabled by using the following option at compile time: --disable-simplexml
, translates to: official versions of PHP include simplexml, but when building PHP from source there is the option to disable simplexml.
Basically simplexml it's always there with the official versions of PHP.
Framework decision required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to add the critical part.
The extensions which can be disabled are not supplied by the package managers (i.e. dnf).
In case someone builds PHP from source using i.e. --disable-simplexml and later on decides he needs ext-simplexml, then he has to build from source simplexml. Now, this is odd indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not linux distribution's package names, but PHP extensions.
I think it is no problem to list those that are listed in composer.
$ composer show --platform | grep ^ext
ext-bcmath 8.1.26 The bcmath PHP extension
ext-bz2 8.1.26 The bz2 PHP extension
ext-calendar 8.1.26 The calendar PHP extension
ext-ctype 8.1.26 The ctype PHP extension
ext-curl 8.1.26 The curl PHP extension
ext-date 8.1.26 The date PHP extension
ext-dba 8.1.26 The dba PHP extension
ext-dom 20031129 The dom PHP extension
ext-exif 8.1.26 The exif PHP extension
ext-ffi 8.1.26 The FFI PHP extension
ext-fileinfo 8.1.26 The fileinfo PHP extension
ext-filter 8.1.26 The filter PHP extension
ext-ftp 8.1.26 The ftp PHP extension
ext-gd 8.1.26 The gd PHP extension
ext-gettext 8.1.26 The gettext PHP extension
ext-gmp 8.1.26 The gmp PHP extension
ext-hash 8.1.26 The hash PHP extension
ext-iconv 8.1.26 The iconv PHP extension
ext-imagick 3.7.0 The imagick PHP extension
ext-intl 8.1.26 The intl PHP extension
ext-json 8.1.26 The json PHP extension
ext-ldap 8.1.26 The ldap PHP extension
ext-libxml 8.1.26 The libxml PHP extension
ext-mbstring 8.1.26 The mbstring PHP extension
ext-memcached 3.2.0 The memcached PHP extension
ext-mysqli 8.1.26 The mysqli PHP extension
ext-mysqlnd 0 The mysqlnd PHP extension (actual version: mysqlnd 8.1.26)
ext-odbc 8.1.26 The odbc PHP extension
ext-openssl 8.1.26 The openssl PHP extension
ext-pcntl 8.1.26 The pcntl PHP extension
ext-pcre 8.1.26 The pcre PHP extension
ext-pdo 8.1.26 The PDO PHP extension
ext-pdo_dblib 8.1.26 The pdo_dblib PHP extension
ext-pdo_mysql 8.1.26 The pdo_mysql PHP extension
ext-pdo_odbc 8.1.26 The PDO_ODBC PHP extension
ext-pdo_pgsql 8.1.26 The pdo_pgsql PHP extension
ext-pdo_sqlite 8.1.26 The pdo_sqlite PHP extension
ext-pgsql 8.1.26 The pgsql PHP extension
ext-phar 8.1.26 The Phar PHP extension
ext-posix 8.1.26 The posix PHP extension
ext-pspell 8.1.26 The pspell PHP extension
ext-readline 8.1.26 The readline PHP extension
ext-redis 5.3.7 The redis PHP extension
ext-reflection 8.1.26 The Reflection PHP extension
ext-session 8.1.26 The session PHP extension
ext-shmop 8.1.26 The shmop PHP extension
ext-simplexml 8.1.26 The SimpleXML PHP extension
ext-soap 8.1.26 The soap PHP extension
ext-sockets 8.1.26 The sockets PHP extension
ext-sodium 8.1.26 The sodium PHP extension
ext-spl 8.1.26 The SPL PHP extension
ext-sqlite3 8.1.26 The sqlite3 PHP extension
ext-sqlsrv 5.11.0 The sqlsrv PHP extension
ext-sysvmsg 8.1.26 The sysvmsg PHP extension
ext-sysvsem 8.1.26 The sysvsem PHP extension
ext-sysvshm 8.1.26 The sysvshm PHP extension
ext-tidy 8.1.26 The tidy PHP extension
ext-tokenizer 8.1.26 The tokenizer PHP extension
ext-xdebug 3.2.1 The xdebug PHP extension
ext-xml 8.1.26 The xml PHP extension
ext-xmlreader 8.1.26 The xmlreader PHP extension
ext-xmlwriter 8.1.26 The xmlwriter PHP extension
ext-xsl 8.1.26 The xsl PHP extension
ext-zend-opcache 8.1.26 The Zend OPcache PHP extension
ext-zip 1.19.5 The zip PHP extension
ext-zlib 8.1.26 The zlib PHP extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, there is ext-json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is not needed.
You can test the validity of this PR with a fresh install, like a fresh VM or bare metal install, clean OS install. Alternatively you can make a thorough uninstall and try from scratch. It's a simple as that - on a fresh install it is not possible to find official PHP extensions:
However these are included in the requirements. It is obvious that since these are provided by default with PHP there will be no issues unless the user tries to install those dependencies and it is not able to find them using the package manager. Automated installers will have to take into account the fact that some requirements are just unavailable, skip install errors and hope everything will go well. This is actually where I'm pointing to:
The requirements are not rigorously correct as they are at the moment. |
Personally, I see no harm in having all these extensions specified. They can be helpful with edge cases when PHP is compiled from source. |
@NicolaeIotu You seem to be confusing OS packages with PHP extensions. Is there an automated installer that behaves in the way you are concerned about? |
When I specified for example I'm gonna go ahead and assume you have ext-imagick installed.
(this should show imagick)
(imagick missing)
(this should show imagick) In this case imagick is an extension which may be required with composer.json. The users will search for it and install corresponding package (which will provide ext-imagick as viewed by php to clarify). Returning to practical stuff, since it is not acceptable for you to exclude default extensions, the only thing which remains to decide is if at least the extension which is part of PHP core can be eliminated from the requirements. That's ext-json. |
The Linux packages are irrelevant. The package maintainer can create these packages as s/he likes. This is a Composer configuration and is about PHP extensions. This configuration is for Composer. If you have missing extensions, Composer reports errors when you install a composer package that requires the extentions. If you have an automated installer that reads |
Alright. All good. Awesome. Let's return to the PR. Anything else will only clutter judgement. Found unifying logic. Let's take a few packages which are used by CodeIgniter: ext-reflection and ext-sodium. What is the precise reason for which composer.json does not include them? Why are these not included in composer.json?
The answer is that these are bundled with php or part of the core. It's pointless to include them. The same applies for many other extensions used by CodeIgniter. |
And yes, we don't need PHP core extensions that are not disabled. |
I see. You probably need to go through and check the rest of the list because I only picked 2 random extensions for my example.
This means you have to exclude ext-json which is core and always enabled. There's a commit above for this change. |
Yes, we now require PHP 8.1+, so we don't need it. |
Okay. Done with admin/framework/composer.json. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Some extensions are included with PHP. It is better to exclude them from requirements as these are most likely unavailable from package managers.
The details of the extensions can be viewed at https://www.php.net/manual/en/extensions.alphabetical.php.
I recommend to open a new tab for each extension of interest and visit section Installation which indicates if it is shipped by default or not.
Checklist: