Search code examples
phpxml

require ext-xml * -> it is missing from your system. Install or enable PHP's xml extension


I'm learning laravel. But after running the command composer update it is showing me this error.

I've already done this -> apt-get install php7.4-xml and apt-get install php-xml

I just want to know which line should I add to the file php.ini to enable the PHP's xml extension. Thanks in Advance.

php--version 

PHP 7.4.22 (cli) (built: Jul 30 2021 13:08:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.22, Copyright (c), by Zend Technologies

Result of composer udpate

    aman@aman-HP-Notebook:~/AMAN/learnLaravel$ composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.



 Problem 1
    - phpunit/phpunit[9.3.3, ..., 9.5.x-dev] require ext-xml * -> it is missing from your system. Install or enable PHP's xml extension.
    - Root composer.json requires phpunit/phpunit ^9.3.3 -> satisfiable by phpunit/phpunit[9.3.3, ..., 9.5.x-dev].To enable extensions, verify that they are enabled in your .ini files:
        - /etc/php/7.4/cli/php.ini
        - /etc/php/7.4/cli/conf.d/10-opcache.ini
        - /etc/php/7.4/cli/conf.d/10-pdo.ini
        - /etc/php/7.4/cli/conf.d/20-calendar.ini
        - /etc/php/7.4/cli/conf.d/20-ctype.ini
        - /etc/php/7.4/cli/conf.d/20-exif.ini
        - /etc/php/7.4/cli/conf.d/20-ffi.ini
        - /etc/php/7.4/cli/conf.d/20-fileinfo.ini
        - /etc/php/7.4/cli/conf.d/20-ftp.ini
        - /etc/php/7.4/cli/conf.d/20-gettext.ini
        - /etc/php/7.4/cli/conf.d/20-iconv.ini
        - /etc/php/7.4/cli/conf.d/20-json.ini
        - /etc/php/7.4/cli/conf.d/20-phar.ini
        - /etc/php/7.4/cli/conf.d/20-posix.ini
        - /etc/php/7.4/cli/conf.d/20-readline.ini
        - /etc/php/7.4/cli/conf.d/20-shmop.ini
        - /etc/php/7.4/cli/conf.d/20-sockets.ini
        - /etc/php/7.4/cli/conf.d/20-sysvmsg.ini
        - /etc/php/7.4/cli/conf.d/20-sysvsem.ini
        - /etc/php/7.4/cli/conf.d/20-sysvshm.ini
        - /etc/php/7.4/cli/conf.d/20-tokenizer.ini
        - /etc/php/7.4/cli/conf.d/20-zip.ini
    You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

result of sudo apt search php-xml

i   php-xml                                                  - DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]       
v   php-xml:i386                                             -                                                                   
p   php-xml-htmlsax3                                         - SAX parser for HTML and other badly formed XML documents          
p   php-xml-rpc2                                             - PHP XML-RPC client/server library                                 
p   php-xml-svg                                              - XML_SVG API                                                       
v   php-xml-util                                             -                                                                   
v   php-xmlreader                                            -                                                                   
v   php-xmlreader:i386                                       -                                                                   
p   php-xmlrpc                                               - XML-RPC servers and clients functions for PHP                     
v   php-xmlrpc:i386                                          -                                                                   
p   php-xmlrpc-all-dev                                       - XML-RPC servers and clients functions for PHP                     
v   php-xmlwriter                                            -                                                                   
v   php-xmlwriter:i386                                       - 

output of php -m

[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Solution

  • I don't know how to answer in a professional way. But I've added only these following three lines in php.ini file by guessing.

    extension=xmlwriter.so
    extension=xml.so
    extension=xmlreader.so
    

    and yes, it is working now.

    Note : In my case, php.ini file is located inside etc/php/7.4/cli. Thanks Toyi for your help and time.