首页 > 解决方案 > 处理 symfony-scripts 事件的脚本 Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache 因异常而终止

问题描述

Heroku 日志:

   > Incenteev\ParameterHandler\ScriptHandler::buildParameters

   Creating the "app/config/parameters.yml" file

   > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap

   > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache



   In AbstractMySQLDriver.php line 103:



     An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused  





   In PDOConnection.php line 47:



     SQLSTATE[HY000] [2002] Connection refused  





   In PDOConnection.php line 43:



     SQLSTATE[HY000] [2002] Connection refused  





   Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception





     [RuntimeException]                                                             

     An error occurred when executing the "'cache:clear --no-warmup'" command:      









     In AbstractMySQLDriver.php line 103:                                           



       An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused    





     In PDOConnection.php line 47:                                                  



       SQLSTATE[HY000] [2002] Connection refused                                    





     In PDOConnection.php line 43:                                                  



       SQLSTATE[HY000] [2002] Connection refused                                    





   install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...



 !     Push rejected, failed to compile PHP app.

 !     Push failed

处理 symfony-scripts 事件的脚本 Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache 因异常而终止

[运行时异常]

执行“'cache:clear --no-warmup'”命令时出错

作曲家.json:

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-4": {
            "AppBundle\\": "src/AppBundle"
        },
        "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
    },
    "autoload-dev": {
        "psr-4": { "Tests\\": "tests/" },
        "files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
    },
    "require": {
        "php": ">=5.5.9",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/orm": "^2.5",
        "easycorp/easyadmin-bundle": "^1.17",
        "friendsofsymfony/user-bundle": "~2.0",
        "incenteev/composer-parameter-handler": "^2.0",
        "knplabs/knp-paginator-bundle": "^2.7",
        "mgilet/notification-bundle": "^2.0",
        "sensio/distribution-bundle": "^5.0.19",
        "sensio/framework-extra-bundle": "^5.0.0",
        "symfony/assetic-bundle": "^2.8",
        "symfony/monolog-bundle": "^3.1.0",
        "symfony/polyfill-apcu": "^1.0",
        "symfony/swiftmailer-bundle": "^2.6.4",
        "symfony/symfony": "3.4.*",
        "symfony/var-dumper": "^3.4",
        "ext-apcu": "^5.1.7",
        "twig/twig": "^1.0||^2.0",
        "vich/uploader-bundle": "^1.4",
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0"

    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0"
    },
    "scripts": {
        "symfony-scripts": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ]
    },
    "config": {
        "platform": {
            "php": "5.5.9"
        },
        "sort-packages": true
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-bin-dir": "bin",
        "symfony-var-dir": "var",
        "symfony-web-dir": "web",
        "symfony-tests-dir": "tests",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "3.4-dev"
        }
    }
}

我更新了 composer 添加了一个 require ext-apcu 和 require generator bundle

我知道问题出在哪里,而且似乎并不常见。

标签: phpsymfonyherokusymfony-3.2heroku-cli

解决方案


可能 Doctrine 正在尝试确定数据库平台版本。

尝试将服务器版本添加到 Doctrine DBAL 配置中(请参阅此处的答案:https ://stackoverflow.com/a/34024275/695091 ):

#config.yml

doctrine:
    dbal:
    ...
        server_version: 5.7

推荐阅读