我正在使用PHP7在Ubuntu 16.04服务器上运行laravel 5.4。尝试安装cviebrock/eloquent-sluggable
包时会抛出一些错误:
pish@let:/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.
在本地版本的应用程序上安装此软件包没有问题。
答案 0 :(得分:238)
首先,阅读警告!它说不将作曲家作为 root 运行! 其次,您可能在本地使用Xammp,默认情况下需要php库。
但是在您的服务器中,您错过了ext-dom
。 php7.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
答案 1 :(得分:62)
谁想要在php 7.1上安装ext-dom并运行此命令:
sudo apt install php-xml
答案 2 :(得分:19)
sudo apt install php-xml
可以工作,但事实是它将下载最新PHP版本的插件。
如果您的PHP版本不是最新的,则可以在其中添加版本:
# PHP 7.1
sudo apt install php7.1-xml
# PHP 7.2:
sudo apt install php7.2-xml
# PHP 7.3
sudo apt install php7.3-xml
# PHP 7.4 (latest)
sudo apt install php-xml
答案 3 :(得分:3)
对于CentOS,RHEL,Fedora:
public function index()
{
$user = User::with('projects')->find(request()->user()->id);
return view ('teams.index', compact('user'));
}
然后选择与您的php版本匹配的 php-xml 版本:
$ yum search php-xml
============================================================================================================ N/S matched: php-xml ============================================================================================================
php-xml.x86_64 : A module for PHP applications which use XML
php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php-xmlseclibs.noarch : PHP library for XML Security
php54-php-xml.x86_64 : A module for PHP applications which use XML
php54-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php55-php-xml.x86_64 : A module for PHP applications which use XML
php55-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php56-php-xml.x86_64 : A module for PHP applications which use XML
php56-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php70-php-xml.x86_64 : A module for PHP applications which use XML
php70-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php71-php-xml.x86_64 : A module for PHP applications which use XML
php71-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php72-php-xml.x86_64 : A module for PHP applications which use XML
php72-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php73-php-xml.x86_64 : A module for PHP applications which use XML
php73-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
答案 4 :(得分:1)
简单运行
sudo apt install php-xml
它为我工作
答案 5 :(得分:0)
我在 Ubuntu 20 上使用 Laravel 8.x 遇到了完全相同的问题。
我在项目目录中运行: foreach (PSObject result in PS.Invoke())
{
foreach (var member in result.Members)
{
if (member.Name == "Licenses")
{
Console.WriteLine(member.Value);
}
};
}
和 sudo apt install php7.4-xml
。这解决了问题。
答案 6 :(得分:0)
首次安装
sudo apt install php-xml
然后如果遇到问题安装mbstring
sudo apt-get install php-mbstring
工作正常
答案 7 :(得分:0)
如果那不起作用,你可能已经做了我所做的。
如果您的默认版本是另一个版本,但您使用 7.4 来安装诸如 Laminas 之类的东西,请通过安装
sudo apt-get install php7.4-"扩展名"