启用php ext-xml?

时间:2017-12-11 18:24:18

标签: php symfony ubuntu

在尝试使用Composer创建Symfony 4项目时,我收到以下错误:

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.

我在php.ini中搜索了ext-xml以查看是否可以取消注释以启用它,但我没有找到提及ext-xml。我没有在其他任何地方搜索,因为我不确定我在做什么。

史蒂夫

非常感谢任何帮助

3 个答案:

答案 0 :(得分:12)

看起来你正在使用ubuntu 16.04和ondrej / php ppa来获取最新版本的php。在这种情况下,包名称需要与您正在使用的php版本匹配:

apt-cache search php | grep xml

您可以通过以下方式查看不同版本:

sudo

根据您的配置,您可能需要在安装命令前添加{{1}}。

答案 1 :(得分:3)

尝试一下 步骤1:

-mcmodel=large

步骤2: 重新启动apache

解决了我的问题

答案 2 :(得分:0)

删除所有版本的php并仅安装一个版本