27

While trying to use Composer to create a Symfony 4 project I got the following error:

steve@laptop ~ $ php composer.phar create-project symfony/skeleton my-proj
Installing symfony/skeleton (v4.0.0)
  - Installing symfony/skeleton (v4.0.0): Loading from cache
Created project in my-proj
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - symfony/framework-bundle v4.0.1 requires ext-xml * -> the requested PHP extension xml is missing from your system.
    - symfony/framework-bundle v4.0.0 requires ext-xml * -> the requested PHP extension xml is missing from your system.
    - Installation request for symfony/framework-bundle ^4.0 -> satisfiable by symfony/framework-bundle[v4.0.0, v4.0.1].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.2/cli/php.ini
    - /etc/php/7.2/cli/conf.d/10-opcache.ini
    - /etc/php/7.2/cli/conf.d/10-pdo.ini
    - /etc/php/7.2/cli/conf.d/20-calendar.ini
    - /etc/php/7.2/cli/conf.d/20-ctype.ini
    - /etc/php/7.2/cli/conf.d/20-exif.ini
    - /etc/php/7.2/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.2/cli/conf.d/20-ftp.ini
    - /etc/php/7.2/cli/conf.d/20-gettext.ini
    - /etc/php/7.2/cli/conf.d/20-iconv.ini
    - /etc/php/7.2/cli/conf.d/20-json.ini
    - /etc/php/7.2/cli/conf.d/20-phar.ini
    - /etc/php/7.2/cli/conf.d/20-posix.ini
    - /etc/php/7.2/cli/conf.d/20-readline.ini
    - /etc/php/7.2/cli/conf.d/20-shmop.ini
    - /etc/php/7.2/cli/conf.d/20-sockets.ini
    - /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.2/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.2/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.2/cli/conf.d/20-tokenizer.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
steve@laptop ~ $ php --ini

    steve@laptop ~ $ php --version
        PHP 7.2.0-2+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Dec  7 2017 20:14:31) ( NTS )
       Copyright (c) 1997-2017 The PHP Group
        Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
        with Zend OPcache v7.2.0-2+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2017, by Zend Technologies
    steve@laptop ~ $ sudo apt-get install php-xml
        [sudo] password for steve: 
        Reading package lists... Done
        Building dependency tree       
        Reading state information... Done
        php-xml is already the newest version (1:7.1+55+ubuntu16.04.1+deb.sury.org+1).
        0 to upgrade, 0 to newly install, 0 to remove and 253 not to upgrade.

I did search in php.ini for ext-xml to see if I could uncomment it in order to enable it but I did not find any mention of ext-xml. I have not searched anywhere else because I am very unsure about what I am doing.

Any help would be very much appreciated, Steve

Sammitch
  • 30,782
  • 7
  • 50
  • 77
user3425506
  • 1,285
  • 1
  • 16
  • 26

4 Answers4

47

It looks like you're using ubuntu 16.04 with the ondrej/php ppa to get the latest version of php. In this case, the package names need to match the version of php you're using:

apt-get install php7.2-xml

You can see the different versions available with something like this:

apt-cache search php | grep xml

Depending on your configuration, you may need to prefix the installation command with sudo.

astrangeloop
  • 1,430
  • 2
  • 13
  • 11
  • Thanks very much. This enabled me to get Symfony 4 working. I am running Linux Mint 18.2 Sonya which I think is based on Ubuntu 16.04. I updated php from ondrej/php ppa which solved a lot of issues relating to getting Symfony 4 but not the php-xml problem. – user3425506 Dec 11 '17 at 19:46
18

Try out Step 1:

sudo apt install php-xml

Step 2: Restart apache

Resolved my issue

Joe Mayo
  • 7,501
  • 7
  • 41
  • 60
Anson Thomas
  • 181
  • 1
  • 2
0

On Amazon linux or Centos

sudo yum install php-xml

if you're running on nginx restarting is not needed

Oscar Gallardo
  • 2,240
  • 3
  • 27
  • 47
-1

Remove all versions for php and install only one version