【问题标题】:Composer install issue on prod, no issues on local enviromentProd 上的 Composer 安装问题,本地环境没有问题
【发布时间】:2018-10-15 09:07:26
【问题描述】:

最近我忽略了 composer.lock 和 package-lock.json(可能不相关),并且我将 gulp 部署脚本更改为使用 composer install 而不是 composer update。在将新代码推送到产品服务器之前,我使用 composer update 和 npm update 将锁定文件更新到最新版本,以确保分支合并中没有任何异常。

但是,gulp 部署脚本遇到了各种问题,其中最成问题的是:“无法将需求解析为可安装的软件包集”

gulp-tasks/deploy.js 处于当前状态:

var args = require('yargs').argv;
var exec = require('./helpers/exec');
var runSequence  = require('run-sequence');

module.exports = function (gulp, plugins, settings) {
    return function (completed) {

        var jsBundle = [];
        // Set production / staging only bundling options
        settings.env === 'production' || settings.env === 'staging'
            ? jsBundle.push('js:bundle-production')
            : jsBundle.push('js:bundle-vendor', 'js:bundle-vue', 'js:bundle-core');

        if (!args.x) { // Exclude mode
            console.log('Fetching latest commits from remote repository..');
            exec('git fetch');

            try {
                console.log('Attempting to merge upstream branch into local..');
                exec('git merge'); // If up-stream set on branch, merge it into local branch
            } catch (e) {}
        }

        if (args.v) { // Checkout version tag
            console.log('Checking out release tag..');
            exec('git checkout tags/' + args.v);
        }

        if (args.s) { // Speed mode
            console.log('Building JS and SASS..');
            runSequence(
                'make:htaccess',
                'sass:compile',
                'js:bundle-login',
                jsBundle,
                'copy-public',
                'remove:config',
                completed
            );
        } else if (args.b) {
            runSequence(
                'make:htaccess',
                'remove:config',
                completed
            );
        } else {
            // Full deploy
            // Create array for additional tasks we can pipe things like bugsnag into (this can't be empty)
            var extraTasks = ['remove:config'];
            if (settings.env === settings.production) {
                extraTasks.push('bugsnag'); // Add Bugsnag source maps on production
            }

            console.log('Installing composer packages..');
            exec('composer install');
            console.log('Installing NPM packages & pruning old packages..');
            exec('npm prune');
            // If deploying to a version then we don't want any potential package or package.lock changes saved
            if (args.v) {
                exec('npm install --no-save');
            } else {
                exec('npm install');
            }
            runSequence(
                'make:htaccess',
                'sass:compile',
                'js:bundle-login',
                jsBundle,
                'copy-public',
                extraTasks,
                completed
            );
        }

        if (args.u) {
            console.log('Running unit tests..');
            try {
                exec('./vendor/bin/phpunit --bootstrap tests/unit/bootstrap.php -c tests/unit/phpunit.xml tests/unit');
            } catch (e) {}
        }

        if (args.y) {
            try {
                console.log('Updating system packages..');
                exec('[ -n "$(which yum)" ]');
                exec('sudo yum -y update');
            } catch (e) {
                console.log('yum not found.');
            }
        }
    }
};

composer.json:

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://wpackagist.org"
        },
        {
            "type": "git",
            "url": "https://company/repo/iputils.git"
        },
        {
            "type": "git",
            "url": "https://company/repo/phpwhois.git"
        }
    ],

    "autoload": {
        "psr-4": {"company\\Database\\": "database/src"}
    },

    "require": {
        "php": ">=7.1",
        "ext-dom": "*",
        "ext-mbstring": "*",
        "ext-pdo": "*",
        "ext-SimpleXML": "*",
        "adobe-marketing-cloud/marketing-cloud-php-sdk": "2.1.x",
        "atrapalo/majesticseo-php-api-connector": "0.9.*",
        "aveiv/open-exchange-rates-api": "1.1",
        "aws/aws-sdk-php": "3.*",
        "bshaffer/oauth2-server-php": "1.10",
        "bugsnag/bugsnag": "^3.0",
        "diggin/diggin-http-charset": "dev-master",
        "eloquent/enumeration": "5.*",
        "google/apiclient": "2.1.*",
        "guzzlehttp/guzzle": "6.*",
        "h4cc/wkhtmltopdf-amd64": "0.12.x",
        "h4cc/wkhtmltoimage-amd64": "0.12.x",
        "intervention/image": "^2.3",
        "knplabs/knp-snappy": "^0.4.3",
        "kunststube/rison": "0.92",
        "league/csv": "^9.0",
        "pelago/emogrifier": "@dev",
        "php-di/php-di": "6.0.x",
        "companyrepo/iputils": "dev-master",
        "companyrepo/phpwhois": "dev-4-stable",
        "ramsey/uuid": "2.8.*",
        "shazam/php-slack": "^0.1.0",
        "sameer-shelavale/php-countries-array": "*",
        "symfony/intl": "^3.1",
        "zendframework/zendframework1": "1.*",
        "zendframework/zendframework": "3.*",
        "zendframework/zend-http": "2.7.0",
        "johnpbloch/wordpress-core-installer": "^1.0",
        "johnpbloch/wordpress-core": "4.9.*",
        "wpackagist-plugin/advanced-text-widget": "2.0.*",
        "wpackagist-plugin/drafts-of-post-revisions": "0.8.*",
        "wpackagist-plugin/image-widget": "4.2.*",
        "wpackagist-plugin/inline-google-spreadsheet-viewer": "0.10.*",
        "wpackagist-plugin/posts-to-posts": "1.6.*",
        "wpackagist-plugin/post-types-order": "1.8.*",
        "wpackagist-plugin/simple-page-ordering": "2.2.*",
        "wpackagist-plugin/wp-migrate-db": "0.*",
        "wpackagist-plugin/wp-cerber": "6.*",
        "zircote/swagger-php": "dev-master",
        "simshaun/recurr": "3.0.5",
        "robmorgan/phinx": "*",
        "fzaninotto/faker": "*"
    },
    "require-dev": {
        "mockery/mockery": "^0.9.4",
        "phpunit/phpunit": "6.*",
        "phploc/phploc": "*",
        "phpmd/phpmd": "*",
        "slevomat/coding-standard": "~4.0",
        "squizlabs/php_codesniffer": "3.*"
    },
    "extra": {
        "wordpress-install-dir": "public/support/wp",
        "installer-paths": {
            "public/support/support-content/plugins/{$name}/": ["type:wordpress-plugin"]
        }
    }
}

我们在生产服务器上运行的部署命令:gulp deploy -v tagversionnumber

来自生产服务器之一的 Composer 诊断示例:

Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
require.aveiv/open-exchange-rates-api : exact version constraints (1.1) should be avoided if the package follows semantic versioning
require.bshaffer/oauth2-server-php : exact version constraints (1.10) should be avoided if the package follows semantic versioning
require.diggin/diggin-http-charset : unbound version constraints (dev-master) should be avoided
require.pelago/emogrifier : unbound version constraints (@dev) should be avoided
require.companyrepo/iputils : unbound version constraints (dev-master) should be avoided
require.sameer-shelavale/php-countries-array : unbound version constraints (*) should be avoided
require.zendframework/zend-http : exact version constraints (2.7.0) should be avoided if the package follows semantic versioning
require.zircote/swagger-php : unbound version constraints (dev-master) should be avoided
require.simshaun/recurr : exact version constraints (3.0.5) should be avoided if the package follows semantic versioning
require.robmorgan/phinx : unbound version constraints (*) should be avoided
require.fzaninotto/faker : unbound version constraints (*) should be avoided
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: WARNING
You are not running the latest stable version, run `composer self-update` to update (1.3.0 => 1.7.2)

一些服务器正在运行 composer 1.2.2

在同一个产品服务器上composer install --dry-run:

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for zendframework/zend-soap 2.7.0 -> satisfiable by zendframework/zend-soap[2.7.0].
    - zendframework/zend-soap 2.7.0 requires ext-soap * -> the requested PHP extension soap is missing from your system.
  Problem 2
    - zendframework/zendframework 3.0.0 requires zendframework/zend-soap ^2.6 -> satisfiable by zendframework/zend-soap[2.7.0].
    - zendframework/zendframework 3.0.0 requires zendframework/zend-soap ^2.6 -> satisfiable by zendframework/zend-soap[2.7.0].
    - zendframework/zend-soap 2.7.0 requires ext-soap * -> the requested PHP extension soap is missing from your system.
    - Installation request for zendframework/zendframework 3.0.0 -> satisfiable by zendframework/zendframework[3.0.0].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php.ini
    - /etc/php-7.1.d/10-opcache.ini
    - /etc/php-7.1.d/20-bz2.ini
    - /etc/php-7.1.d/20-calendar.ini
    - /etc/php-7.1.d/20-ctype.ini
    - /etc/php-7.1.d/20-curl.ini
    - /etc/php-7.1.d/20-dom.ini
    - /etc/php-7.1.d/20-exif.ini
    - /etc/php-7.1.d/20-fileinfo.ini
    - /etc/php-7.1.d/20-ftp.ini
    - /etc/php-7.1.d/20-gd.ini
    - /etc/php-7.1.d/20-gettext.ini
    - /etc/php-7.1.d/20-iconv.ini
    - /etc/php-7.1.d/20-imap.ini
    - /etc/php-7.1.d/20-json.ini
    - /etc/php-7.1.d/20-mbstring.ini
    - /etc/php-7.1.d/20-mysqlnd.ini
    - /etc/php-7.1.d/20-pdo.ini
    - /etc/php-7.1.d/20-phar.ini
    - /etc/php-7.1.d/20-posix.ini
    - /etc/php-7.1.d/20-shmop.ini
    - /etc/php-7.1.d/20-simplexml.ini
    - /etc/php-7.1.d/20-sockets.ini
    - /etc/php-7.1.d/20-sqlite3.ini
    - /etc/php-7.1.d/20-sysvmsg.ini
    - /etc/php-7.1.d/20-sysvsem.ini
    - /etc/php-7.1.d/20-sysvshm.ini
    - /etc/php-7.1.d/20-tokenizer.ini
    - /etc/php-7.1.d/20-xml.ini
    - /etc/php-7.1.d/20-xmlwriter.ini
    - /etc/php-7.1.d/20-xsl.ini
    - /etc/php-7.1.d/20-zip.ini
    - /etc/php-7.1.d/30-mysqli.ini
    - /etc/php-7.1.d/30-pdo_mysql.ini
    - /etc/php-7.1.d/30-pdo_sqlite.ini
    - /etc/php-7.1.d/30-wddx.ini
    - /etc/php-7.1.d/30-xmlreader.ini
    - /etc/php-7.1.d/40-apcu.ini
    - /etc/php-7.1.d/php.ini

注意 ext-soap 也不在我们的本地环境中,但在那里安装可以正常工作。并且 composer update 在 prod 和 local 上都可以正常工作

【问题讨论】:

  • 可能不相关,但在生产中您很可能希望使用composer install --no-dev
  • 谢谢@Furgas 我会补充的

标签: php npm gulp composer-php


【解决方案1】:

您应该安装并启用 php-soap 扩展。

zendframework/zend-soap 2.7.0 requires ext-soap * -> the requested PHP extension soap is missing from your system.

【讨论】:

  • 在我安装扩展之前,因为 composer 声称它们丢失了影响作曲家更新。
  • 谢谢,在写完评论后,我去仔细检查了一些东西。出于某种原因,最近部署的人确实安装了它,但其他人没有,所以我们的开发环境有问题。值得庆幸的是,无论如何,我们本周只是将环境更改为 docker。我一定会添加这个扩展
猜你喜欢
  • 1970-01-01
  • 2019-02-07
  • 2014-10-04
  • 1970-01-01
  • 2013-08-26
  • 1970-01-01
  • 1970-01-01
  • 2021-03-05
  • 1970-01-01
相关资源
最近更新 更多