作曲家要求 phpoffice/phpspreadsheet 不工作

composer require phpoffice/phpspreadsheet don't work

最初,我需要一个可以帮助我将数据上传到 Excel 的库,找到了这个库,然后出现了问题

我尝试安装 composer 需要 phpoffice/phpspreadsheet 但我有问题

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested PHP extension ext-spltype * is missing from your system. Install or enable PHP's spltype extension.


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

我不明白错误来自哪里,因为我的composer.json

中有一个依赖项“ext-spltype”:“*”

这是我的composer.json

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "sensio/framework-extra-bundle": "^5.5",
        "symfony/asset": "5.1.*",
        "symfony/console": "5.1.*",
        "symfony/dotenv": "5.1.*",
        "symfony/expression-language": "5.1.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.1.*",
        "symfony/framework-bundle": "5.1.*",
        "symfony/http-client": "5.1.*",
        "symfony/intl": "5.1.*",
        "symfony/mailer": "5.1.*",
        "symfony/mime": "5.1.*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/notifier": "5.1.*",
        "symfony/orm-pack": "^1.0",
        "symfony/process": "5.1.*",
        "symfony/security-bundle": "5.1.*",
        "symfony/serializer-pack": "*",
        "symfony/string": "5.1.*",
        "symfony/translation": "5.1.*",
        "symfony/twig-pack": "^1.0",
        "symfony/validator": "5.1.*",
        "symfony/web-link": "5.1.*",
        "symfony/yaml": "5.1.*",
      "ext-spltype": "*"
    },
    "require-dev": {
        "symfony/debug-pack": "*",
        "symfony/maker-bundle": "^1.19",
        "symfony/profiler-pack": "*",
        "symfony/test-pack": "*"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\Tests\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.1.*"
        }
    }
}

我也尝试安装 sudo pecl install SPL_Types ,但我有错误

这是一个 PHP PECL 扩展,它的安装由 composer 管理: https://www.php.net/manual/en/spl-types.installation.php

Composer 只是检查它是否存在,如果不存在则失败。

我正在使用 Ubuntu 18.04 和 Apache。使用此处的脚本有效。

sudo apt-get install libpcre3-dev php5-dev php-pear -y
sudo pecl install SPL_Types
echo extension=spl_types.so | sudo tee /etc/php5/mods-available/spl_types.ini
sudo php5enmod spl_types
sudo service apache2 reload

我从 composer.json 中删除了“ext-spltype”:“*”,现在可以使用了