【问题标题】:Symfony 3.3 ScriptHandler is not autoloadableSymfony 3.3 ScriptHandler 不可自动加载
【发布时间】:2018-04-18 14:17:07
【问题描述】:

我正在使用 Capistrano 3.10.0 和 gitlab-ci(和 docker)部署到生产环境,但 composer 1.5.2 似乎没有自动加载 ScriptHandler。
注意:composer.lock 是最新的。

这里是 capistrano 错误:

01 Generating optimized autoload files
01 > Incenteev\ParameterHandler\ScriptHandler::buildParameters
01 Updating the "app/config/parameters.yml" file
01 Class Sensio\Bundle\DistributionBundle\Composer\ScriptHandler is not autoloadable, can not call symfony-scripts script
01 Class Sensio\Bundle\DistributionBundle\Composer\ScriptHandler is not autoloadable, can not call symfony-scripts script
01 Class Sensio\Bundle\DistributionBundle\Composer\ScriptHandler is not autoloadable, can not call symfony-scripts script
01 Class Sensio\Bundle\DistributionBundle\Composer\ScriptHandler is not autoLoadable, can not call symfony-scripts script
01 Class Sensio\Bundle\DistributionBundle\Composer\ScriptHandler is not autoloadable, can not call symfony-scripts script
01 deploy@IP 3.002s
00:07 npm:install
01 npm install --production --silent --no-progress
01 added 3 packages in 0.619s
01 deploy@IP 2.613s
00:10 deploy:set_permissions:check
ERROR Cannot change permissions: /home/app/releases/20171106125307/var/logs is not a file or directory (Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@IP: Cannot change permissions: /home/app/releases/20171106125307/var/logs is not a file or directory

var/logs 目录未创建,部署随即失败。

composer.json:

{
    "name": "MyApp",
    "description": "MyApp description",
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-4": {
            "": "src/"
        },
        "classmap": [
            "app/AppKernel.php",
            "app/AppCache.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "require": {
        "php": ">=7.0",
        "ext-mbstring": "*",
        "ext-soap": "*",
        "symfony/symfony": "^3.3",
        "doctrine/orm": "^2.5",
        "doctrine/doctrine-bundle": "^1.6",
        "symfony/swiftmailer-bundle": "^2.3",
        "symfony/monolog-bundle": "^3.0",
        "symfony/polyfill-apcu": "^1.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "symfony/assetic-bundle": "^2.8",
        "nesbot/carbon": "^1.22",
        "symfony/workflow": "^3.3",
        "twig/extensions": "^1.4",
        "stof/doctrine-extensions-bundle": "^1.2",
        "csa/guzzle-bundle": "^2.0",
        "symfony/dotenv": "^3.3",
        "sensio/distribution-bundle": "^5.0",
        "beberlei/assert": "^2.7"
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0",
        "doctrine/doctrine-fixtures-bundle": "^2.3",
        "fzaninotto/faker": "^1.6",
        "friendsofphp/php-cs-fixer": "^2.6",
        "phpunit/phpunit": "^5.6",
        "jakub-onderka/php-parallel-lint": "^0.9.2",
        "edgedesign/phpqa": "^1.16"
    },
    "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"
        ]
    },
    "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": null
    }
}

有什么遗漏吗?

【问题讨论】:

  • 你的作曲家版本是多少?
  • 1.2.2,但这很奇怪,我不能用 apt (Debian 9) 更新它
  • 与1.5.2 相同的错误(当前)
  • 检查您的自动加载部分,尝试使用 "AppBundle\\": "src/AppBundle"
  • 谢谢,但我仍然有同样的错误

标签: symfony composer-php capistrano autoload gitlab-ci


【解决方案1】:

gitlab-ci 和 capistrano 之间存在混乱。我正在尝试使用开发分支部署到生产环境,而 capistrano 正在获取 master(带有 composer.json 错误)...

上述配置正在运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-17
    • 2013-01-03
    • 1970-01-01
    • 2013-12-30
    • 1970-01-01
    • 2014-05-26
    • 1970-01-01
    • 2012-05-10
    相关资源
    最近更新 更多