我无法使用composer安装php电子表格



我正在尝试使用php将excel数据导入mysql,并尝试安装composer require phpoffice/phpspreadsheet但是下面的错误总是出现。

Installation failed, deleting ./composer.json.
In RequireCommand.php line 217:
                                                    
No composer.json present in the current directory (./composer.json), this may be the cause of the following exception.  
                                                    
In PackageDiscoveryTrait.php line 313:
                                                        
Package phpoffice/phpspreadsheet has requirements incompatible with your PHP version, PHP extensions and Composer version:  
- phpoffice/phpspreadsheet 1.25.2 requires ext-zip * but it is not present.

起初,我以为我是因为我的php版本。我正在maco上运行带有php7.3的xampp。它不起作用。我试着把它安装在运行php7.4的windows PC上,它运行得很好。

所以我删除了我的7.3版本,并将7.4版本安装到我的mac中。它也不起作用。

目录中没有compomposer.json。当开始一个新项目时,你应该首先运行

composer init

初始化composer.json中的值会遇到一些问题,这些值基本上与您可以作为参数传递给命令的值相同:https://getcomposer.org/doc/03-cli.md#init

之后,您可以运行composer来安装包

最新更新