0

语境

我目前正在开发一个基于 Symfony 4.4 并部署在Platform.sh上的 OroPlatform 项目。

我在部署的构建阶段面临以下问题:

  • 我的应用需要包symfony/process4.4.X
  • 我不知道为什么,但是在 Platform.sh 服务器上,我的应用程序使用symfony/process为全局安装的 composer 二进制文件安装的包,但是这个是 5.X 版本
  • 所以,我遇到了一个错误,我无法安装我的应用程序,因为它使用的是 5.X 版本而不是 4.X
  • 这就是为什么我找到了使用 Composer 1.9.3 的解决方法的原因,因为它使用symfony/process4.4.X,我的应用程序也使用相同的版本。

它运行良好,但昨天由于 Github OAuth 令牌更改,我不得不将作曲家版本提升到最新的 1.X:https ://nono.ma/github-oauth-token-for-github-com-contains-invalid -作曲家上的字符安装

问题

所以,我仍然面临 4.X 版本和 5.X 版本的这个问题。

我试图以这种方式安装我的项目的依赖项:composer install -n -o -a但错误仍然存​​在。

我正在寻找一种方法来强制我的项目使用位于vendor我的应用程序文件夹中的依赖项,而不是全局安装的依赖项。这是 Platform.sh 服务器上问题的屏幕截图:

在此处输入图像描述

这是我的应用程序和作曲家在 Platform.sh 服务器上的路径模式:

/app
|
|__/vendor/symfony-process
|
|__/.global/vendor/symfony-process

我的作曲家.json:

{
    "name": "oro/platform-application",
    "description": "Oro Platform Empty Application",
    "homepage": "https://github.com/oroinc/platform-application.git",
    "license": "MIT",
    "autoload": {
        "psr-4": {
            "": "src/"
        },
        "classmap": [
            "src/AppKernel.php",
            "src/AppCache.php",
            "vendor/oro/platform/guzzle/Client.php"
        ],
        "exclude-from-classmap": [
            "/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php",
            "**/Tests/"
        ]
    },
    "repositories": {
        "composer": {
            "type": "composer",
            "url": "https://packagist.orocrm.com"
        }
    },
    "require": {
        "php": "~7.3.13 || ~7.4.2",
        "oro/platform": "4.1.*",
        "oro/platform-serialised-fields": "4.1.*",
        "oro/oauth2-server": "4.1.*",
        "doctrine/doctrine-migrations-bundle": "^3.0"
    },
    "require-dev": {
        "behat/behat": "3.4.*",
        "behat/gherkin": "4.6.0",
        "behat/mink": "dev-master#6d637f7af4816c26ad8a943da2e3f7eef1231bea",
        "behat/mink-extension": "2.3.*",
        "behat/mink-selenium2-driver": "1.3.1",
        "behat/symfony2-extension": "2.1.*",
        "guzzlehttp/guzzle": "^6.0.0",
        "nelmio/alice": "3.6.*",
        "theofidry/alice-data-fixtures": "1.0.*",
        "phpunit/phpunit": "7.5.*",
        "johnkary/phpunit-speedtrap": "3.0.*",
        "mybuilder/phpunit-accelerator": "dev-master",
        "squizlabs/php_codesniffer": "3.5.*",
        "phpmd/phpmd": "2.6.*",
        "sebastian/phpcpd": "4.0.*",
        "phpunit/phpcov": "5.0.*",
        "symfony/phpunit-bridge": "4.4.*",
        "friendsofphp/php-cs-fixer": "2.16.*",
        "oro/twig-inspector": "1.0.*"
    },
    "config": {
        "component-dir": "public/bundles/components",
        "bin-dir": "bin",
        "fxp-asset": {
            "enabled": false
        }
    },
    "scripts": {
        "post-install-cmd": [
            "@build-parameters",
            "@set-permissions",
            "@install-assets",
            "@set-assets-version"
        ],
        "post-update-cmd": [
            "@build-parameters",
            "@set-permissions",
            "@update-assets",
            "@set-assets-version"
        ],
        "build-parameters": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ],
        "set-permissions": [
            "Oro\\Bundle\\InstallerBundle\\Composer\\ScriptHandler::setPermissions"
        ],
        "install-assets": [
            "Oro\\Bundle\\InstallerBundle\\Composer\\ScriptHandler::installAssets"
        ],
        "update-assets": [
            "Oro\\Bundle\\InstallerBundle\\Composer\\ScriptHandler::updateAssets"
        ],
        "set-assets-version": [
            "Oro\\Bundle\\InstallerBundle\\Composer\\ScriptHandler::setAssetsVersion"
        ],
        "set-parameters": [
            "Oro\\Bundle\\InstallerBundle\\Composer\\ParametersHandler::set"
        ]
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "extra": {
        "symfony": {
            "require": "4.4.*"
        },
        "symfony-web-dir": "public",
        "symfony-var-dir": "var",
        "symfony-bin-dir": "bin",
        "symfony-tests-dir": "tests",
        "incenteev-parameters": {
            "file": "config/parameters.yml"
        }
    }
}
4

2 回答 2

0

最后,我认为将 composer 安装在与 Web 应用程序相同的文件夹下似乎不是一个好习惯。此外,似乎 Platform.sh 不使用作曲家二进制文件。

因此,我已经更改了我的构建阶段,.platform.app.yaml以避免 Platform.sh 安装 Composer 的方式并使用自定义方式来完成它:

# .platform.app.yaml
hooks:
  build: |
    set -e
    cd $PLATFORM_APP_DIR

    # install Composer
    chmod +x composer-install.sh
    ./composer-install.sh

# composer-install.sh

#!/bin/sh

EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"

if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
    >&2 echo 'ERROR: Invalid installer checksum'
    rm composer-setup.php
    exit 1
fi

php composer-setup.php --1 --quiet
RESULT=$?
rm composer-setup.php
>&1 echo 'Composer successfully installed'
exit $RESULT
于 2021-05-24T14:48:39.063 回答
-1

尝试安装该软件包,以便将其添加到您的 composer.json 文件中。

composer install symfony/process

以下部分将导致安装正确的版本

"extra": {
        "symfony": {
            "require": "4.4.*"
        },

运行命令后,应按如下方式添加包:

"symfony/process": "4.4.*"

如果没有,请将其更改为该版本号并运行

composer update symfony/process
于 2021-05-23T17:17:45.417 回答