Andrei
Andrei

Reputation: 171

How to disable PHP extensions that I don't use?

PHP 8, by default, has an entire list of extensions which can't be removed. Or, at least, I can't see a way to removed them using php.ini.

The list of those which can't be removed is this:

Core
PDO
Phar
Reflection
SPL
SimpleXML
apache2handler
bcmath
calendar
ctype
date
dom
filter
hash
iconv
json
libxml
mysqlnd
pcre
readline
session
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib
  1. I may not want to use the zip extension at all. Then why can't be removed ?
  2. There is any way to get the list of extensions which can't be disabled ?

Upvotes: 2

Views: 2879

Answers (1)

Alex Howansky
Alex Howansky

Reputation: 53563

Whether or not a module is "removable" depends on how it was compiled. For example, you can compile each module as a built-in:

./configure --with-zip

Or as shared:

./configure --with-zip=shared

In the former case, the module will be included directly in the PHP binary. It can not be removed -- if you really don't want it, you'd have to recompile without specifying --with-zip.

In the latter case, you'll get a separate zip.so file that contains all the module code, and gets loaded at runtime. This module can be "removed" simply by commenting out (or deleting) the appropriate extension=zip.so in the php.ini file. This doesn't actually uninstall anything, it just tells PHP not to load the shared module when it starts.

Upvotes: 2

Related Questions