[英]Composer require phpoffice/phpspreadsheet doesn't work
我想使用包 Phpspreadsheet 編寫一個腳本。 我沒有php經驗。 我正在嘗試通過 sudo composer require phpoffice/phpspreadsheet 添加對我的腳本的引用。 但它不起作用。 我收到錯誤消息:安裝失敗,刪除 composer.json....如果不知道它為什么不工作。 任何的想法?
詳細錯誤:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for phpoffice/phpspreadsheet ^1.0 -> satisfiable by phpoffice/phpspreadsheet[1.0.0].
- phpoffice/phpspreadsheet 1.0.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
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-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-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.
所以我應該安裝
sudo apt install php-xml
sudo apt install php7.0-gd
sudo apt install php7.0-mbstring
sudo apt install php-zip
也在運行 composer install/update 或安裝新包時添加
--ignore-platform-reqs
在命令末尾,同時為不同環境成功添加/安裝。
在 Centos 中:
須藤 yum 安裝 gd gd-devel php-gd
sudo apt 安裝 php-xml
sudo apt 安裝 php7.0-gd
sudo apt 安裝 php7.0-mbstring
sudo apt 安裝 php-zip
我有同樣的問題,我通過這樣做來解決它
composer install --ignore-platform-reqs
請閱讀錯誤消息“需要 ext-dom”。 它抱怨缺少軟件包或在這種情況下是 php 擴展。 通常,當您無法安裝某個軟件包時,您可以在其 composer.json 中查看所需的軟件包以查看完整列表。
phpoffice(在本例中為 1.1.0)需要以下內容:
"require": {
"php": "^5.6|^7.0",
"ext-ctype": "*",
"ext-dom": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-SimpleXML": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
"psr/simple-cache": "^1.0"
},
"require-dev": {
"tecnickcom/tcpdf": "^6.2",
"squizlabs/php_codesniffer": "^2.7",
"phpunit/phpunit": "^5.7",
"dompdf/dompdf": "^0.8.0",
"mpdf/mpdf": "^7.0.0",
"jpgraph/jpgraph": "^4.0",
"friendsofphp/php-cs-fixer": "@stable"
},
錯誤信息顯示未命中。 我有同樣的問題,通過這樣做來解決它。 請閱讀錯誤消息“需要 ext-dom”。
請安裝php7.1-dom
就我而言,PHP 低於 7.1 是我所做的並且現在正在工作。
sudo apt-get install php7.1 php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7. 1-fpm sudo apt install php-xml php7.1-gd php7.1-dom
如果你正在使用
$sheet->setAutoFilter();
嘗試評論這個來測試
//$sheet->setAutoFilter();
為我工作
類型
php -v
如果 php7 類型
sudo apt install php-xml
sudo apt install php7.0-gd
sudo apt install php7.0-mbstring
sudo apt install php-zip
如果 php8 類型
sudo apt install php-xml
sudo apt install php8.0-gd
sudo apt install php8.0-mbstring
sudo apt install php-zip
我遇到了同樣的問題,我使用命令composer install --ignore-platform-reqs
解決了它
如果您是 Arch 用戶,請編輯/etc/php74/php.ini
或您使用的任何版本。 確保已安裝擴展並且取消注釋 gd 擴展。
extension=gd
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.