2017-04-14 87 views
40

我在使用PHP7的Ubuntu 16.04服務器上運行laravel 5.4。要安裝cviebrock/eloquent-sluggable包拋出一些錯誤:PHP7:安裝ext-dom問題

[email protected]:/home/sherk/ftp/www$ sudo composer require cviebrock/eloquent-sluggable 
Do not run Composer as root/super user! See https://getcomposer.org/root for details 
Using version ^4.2 for cviebrock/eloquent-sluggable 
./composer.json has been updated 
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 
    - phpunit/php-code-coverage 4.0.7 requires ext-dom * -> the requested PHP extension dom is missing from your system. 
    - phpunit/php-code-coverage 4.0.7 requires ext-dom * -> the requested PHP extension dom is missing from your system. 
    - Installation request for phpunit/php-code-coverage (installed at 4.0.7) -> satisfiable by phpunit/php-code-coverage[4.0.7]. 

    To enable extensions, verify that they are enabled in those .ini files: 
    - /etc/php/7.0/cli/php.ini 
    - /etc/php/7.0/cli/conf.d/10-mysqlnd.ini 
    - /etc/php/7.0/cli/conf.d/10-opcache.ini 
    - /etc/php/7.0/cli/conf.d/10-pdo.ini 
    - /etc/php/7.0/cli/conf.d/20-calendar.ini 
    - /etc/php/7.0/cli/conf.d/20-ctype.ini 
    - /etc/php/7.0/cli/conf.d/20-exif.ini 
    - /etc/php/7.0/cli/conf.d/20-fileinfo.ini 
    - /etc/php/7.0/cli/conf.d/20-ftp.ini 
    - /etc/php/7.0/cli/conf.d/20-gd.ini 
    - /etc/php/7.0/cli/conf.d/20-gettext.ini 
    - /etc/php/7.0/cli/conf.d/20-iconv.ini 
    - /etc/php/7.0/cli/conf.d/20-json.ini 
    - /etc/php/7.0/cli/conf.d/20-mbstring.ini 
    - /etc/php/7.0/cli/conf.d/20-mcrypt.ini 
    - /etc/php/7.0/cli/conf.d/20-mysqli.ini 
    - /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini 
    - /etc/php/7.0/cli/conf.d/20-phar.ini 
    - /etc/php/7.0/cli/conf.d/20-posix.ini 
    - /etc/php/7.0/cli/conf.d/20-readline.ini 
    - /etc/php/7.0/cli/conf.d/20-shmop.ini 
    - /etc/php/7.0/cli/conf.d/20-sockets.ini 
    - /etc/php/7.0/cli/conf.d/20-sysvmsg.ini 
    - /etc/php/7.0/cli/conf.d/20-sysvsem.ini 
    - /etc/php/7.0/cli/conf.d/20-sysvshm.ini 
    - /etc/php/7.0/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. 

Installation failed, reverting ./composer.json to its original content. 

我對應用程序的本地版本安裝此軟件包沒有問題。

回答

92

首先,閱讀警告!它說做不是運行作曲者爲! 其次,你可能在你的本地使用了Xammp,默認情況下需要php庫。

但在您的服務器上,您缺少ext-domphp7.1-xml有你需要的所有相關軟件包。所以,你可以簡單地通過運行安裝它:

sudo apt-get update 
sudo apt-get install php7.1-xml 

最有可能你失蹤mbstring太。如果你得到錯誤,安裝該軟件包以及與:

sudo apt-get install php-mbstring 

然後運行:

composer update 
composer require cviebrock/eloquent-sluggable 
+0

感謝。如果我不使用'sudo'來運行作曲家,可以得到這個錯誤:'無法讀取/home/pish/.composer/auth.json file_get_contents(/home/pish/.composer/auth.json):無法打開流:權限被拒絕' – alex

+2

它的權限問題搜索chmod和chown命令。更改此文件夾的權限和所有者,你會沒事的。 –

+0

@rodrane你的代碼中存在一個用於安裝'php-mbstring'軟件包的錯誤,它應該是'sudo apt-get'。除此之外;它的作用就像一種魅力。謝謝! –