Laravel将版本添加到Composer.json Postautoloddump失败



我的laravel 5.6项目的作曲家。

所以我添加到我的composer.json:

"version": "0.1.0"

之后,当我运行composer installcomposer update foo/barcomposer dump-autoload时,发生以下错误:

> IlluminateFoundationComposerScripts::postAutoloadDump
> @php artisan package:discover
PHP Fatal error:  Uncaught Error: Call to undefined method SymfonyComponentProcessProcessUtils::escapeArgument() in phar:///usr/local/bin/composer/src/Composer/Util/ProcessExecutor.php:134
Stack trace:
#0 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(260): ComposerUtilProcessExecutor::escape('1')
#1 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(232): ComposerEventDispatcherEventDispatcher->getPhpExecCommand()
#2 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(96): ComposerEventDispatcherEventDispatcher->doDispatch(Object(ComposerScriptEvent))
#3 phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php(312): ComposerEventDispatcherEventDispatcher->dispatchScript('post-autoload-d...', true, Array, Array)
#4 phar:///usr/local/bin/composer/src/Composer/Installer.php(301): ComposerAutoloadAutoloadGenerator->dump(Object(ComposerConfig), Object(ComposerRepositoryInstalledFilesystemRepository), Object in phar:///usr/local/bin/composer/src/Composer/Util/ProcessExecutor.php on line 134
Fatal error: Uncaught Error: Call to undefined method SymfonyComponentProcessProcessUtils::escapeArgument() in phar:///usr/local/bin/composer/src/Composer/Util/ProcessExecutor.php:134
Stack trace:
#0 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(260): ComposerUtilProcessExecutor::escape('1')
#1 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(232): ComposerEventDispatcherEventDispatcher->getPhpExecCommand()
#2 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(96): ComposerEventDispatcherEventDispatcher->doDispatch(Object(ComposerScriptEvent))
#3 phar:///usr/local/bin/composer/src/Composer/Autoload/AutoloadGenerator.php(312): ComposerEventDispatcherEventDispatcher->dispatchScript('post-autoload-d...', true, Array, Array)
#4 phar:///usr/local/bin/composer/src/Composer/Installer.php(301): ComposerAutoloadAutoloadGenerator->dump(Object(ComposerConfig), Object(ComposerRepositoryInstalledFilesystemRepository), Object in phar:///usr/local/bin/composer/src/Composer/Util/ProcessExecutor.php on line 134

当我删除version指示符时,一切都按预期工作。

这是我的composer.json

{
    "name": "myvendor/myproject",
    "description": "",
    "keywords": [],
    "license": "MIT",
    "version": "0.1.0",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.6.*",
        "laravel/tinker": "^1.0"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^2.4",
        "doctrine/dbal": "^2.6",
        "filp/whoops": "^2.0",
        "friendsofphp/php-cs-fixer": "^2.10",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r "file_exists('.env') || copy('.env.example', '.env');""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

所以它告诉我SymfonyComponentProcessProcessUtils::escapeArgument不确定。我还找到了https://github.com/laravel/framework/issues/21281和https://github.com/eyewitness/eye/eye/issues/8,但是我在整理问题的情况下都遇到了问题。

再次,当我从composer.json中删除version时,问题已经消失了。

结果表明,错误是由我使用的作曲家版本引起的。

我使用的是Laradock环境,composer --verison1.5.5。将作曲家更新为1.6.3后,问题已经消失。

但是,如果您遇到相同的问题,您很可能会遇到相同的困难,并在Laradock的工作区容器中更新作曲家。您不能简单地在那里composer selfupdate,因为由于权限设置,作曲家会在将临时文件移至/usr/local/bin时会遇到问题。

我通过将以下部分添加到我的laradock/workspace/dockerfile-72:

来修复它。
#####################################
# Composer:
#####################################
## FIX laradock/workspace permission problem
USER root
RUN rm /usr/local/bin/composer
USER laradock
RUN cd /home/laradock && php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && 
    php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && 
    php composer-setup.php && 
    php -r "unlink('composer-setup.php');"
USER root 
RUN mv /home/laradock/composer.phar /usr/local/bin/composer
## ENDFIX

我猜,问题是,https://github.com/laradock/workspace/blob/master/master/dockerfile-72不执行Composer-setup.php(请参阅@raaghu的答案:在此处参见答案:拒绝许可作曲家/usr/local/bin/(。

也许只需将其添加到laradock/workspace dockerfile:

,就可以更容易解决问题。
USER root
RUN chown laradock:laradock /usr/local/bin/composer

但我没有测试此设置,我不确定。

相关内容

  • 没有找到相关文章

最新更新