gpt4 book ai didi

symfony - fatal error :在安装 Composer 之后,方法class @ anonymous::__ toString()不得引发异常

转载 作者:行者123 更新时间:2023-12-03 15:53:21 29 4
gpt4 key购买 nike

你好,我在做 Composer 安装时出现错误,并且缓存:清除。

  • 我使用 Symfony 4.1
  • 我已经删除了/var和/vendor
  • 我在Docker(php)上

  • composer install
    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
    Nothing to install or update
    Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead.
    Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
    Package symfony/lts is abandoned, you should avoid using it. Use symfony/flex instead.
    Package symfony/webpack-encore-pack is abandoned, you should avoid using it. Use symfony/webpack-encore-bundle instead.
    Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.
    Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.
    Generating autoload files
    composer/package-versions-deprecated: Generating version class...
    composer/package-versions-deprecated: ...done generating version class
    102 packages you are using are looking for funding.
    Use the `composer fund` command to find out more!

    Run composer recipes at any time to see the status of your Symfony recipes.

    Executing script cache:clear [KO]
    [KO]
    Script cache:clear returned with error code 255
    !! Xdebug: [Config] Invalid mode '1' set for 'xdebug.mode' configuration setting (See: https://xdebug.org/docs/errors#CFG-C-MODE)
    !!
    !! Fatal error: Method class@anonymous::__toString() must not throw an exception, caught Symfony\Component\DependencyInjection\Exception\AutowiringFailedException: in /var/www/symfony/vendor/symfony/dependency-injection/Compiler/AutowirePass.php on line 236
    !!
    !! Call Stack:
    !! 0.0004 403344 1. {main}() /var/www/symfony/bin/console:0
    !! 0.1875 2144496 2. Symfony\Bundle\FrameworkBundle\Console\Application->run($input = class Symfony\Component\Console\Input\ArgvInput
    !! 5.8396 32162400 18. Symfony\Component\DependencyInjection\Compiler\AutowirePass->Symfony\Component\DependencyInjection\Compiler\{closure:/var/www/symfony/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:229-241}() /var/www/symfony/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:261
    !!
    !!
    !! In AutowirePass.php line 236:
    !!
    !! Error: Method class@anonymous::__toString() must not throw an exception, ca
    !! ught Symfony\Component\DependencyInjection\Exception\AutowiringFailedExcept
    !! ion:
    !!
    !!
    !!
    Script @auto-scripts was called via post-install-cmd

    我试图按照此 issue进行操作,但没有任何效果(不适用于我自己开发)
    我的composer.json
    {
    "type": "project",
    "license": "proprietary",
    "require": {
    "php": "^7.1.3",
    "ext-iconv": "*",
    "accord/mandrill-swiftmailer-bundle": "^1.3",
    "api-platform/api-pack": "^1.1",
    "composer/package-versions-deprecated": "1.11.99.1",
    "doctrine/doctrine-bundle": "^1.0",
    "doctrine/doctrine-migrations-bundle": "^2.2",
    "doctrine/orm": "^2.7",
    "friendsofsymfony/ckeditor-bundle": "^2.1",
    "friendsofsymfony/user-bundle": "~2.0",
    "knplabs/knp-paginator-bundle": "^4.0",
    "paragonie/random_compat": "^2.0",
    "ramsey/uuid-doctrine": "^1.4",
    "sensio/framework-extra-bundle": "^5.1",
    "sentry/sentry-symfony": "^3.1",
    "stof/doctrine-extensions-bundle": "^1.3",
    "symfony/asset": "^4.1",
    "symfony/console": "^4.1",
    "symfony/dotenv": "^4.1",
    "symfony/expression-language": "^4.1",
    "symfony/flex": "^1.0",
    "symfony/form": "^4.1",
    "symfony/framework-bundle": "^4.1",
    "symfony/lts": "^4@dev",
    "symfony/monolog-bundle": "^3.1",
    "symfony/process": "^4.1",
    "symfony/security-bundle": "^4.1",
    "symfony/serializer-pack": "*",
    "symfony/swiftmailer-bundle": "^3.1",
    "symfony/translation": "^4.1",
    "symfony/twig-bundle": "^4.1",
    "symfony/validator": "^4.1",
    "symfony/web-link": "^4.1",
    "symfony/webpack-encore-pack": "*",
    "symfony/yaml": "^4.1",
    "vich/uploader-bundle": "^1.9"
    },
    "require-dev": {
    "hautelook/alice-bundle": "^2.0",
    "doctrine/data-fixtures": "^1.3",
    "behat/behat": "^3.4",
    "symfony/debug-pack": "*",
    "symfony/maker-bundle": "^1.0",
    "symfony/phpunit-bridge": "^4.1",
    "symfony/profiler-pack": "*",
    "symfony/test-pack": "^1.0",
    "symfony/web-server-bundle": "^4.1"
    },
    "config": {
    "preferred-install": {
    "*": "dist"
    },
    "sort-packages": true
    },
    "autoload": {
    "psr-4": {
    "App\\": "src/"
    }
    },
    "autoload-dev": {
    "psr-4": {
    "App\\Tests\\": "tests/"
    }
    },
    "replace": {
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php71": "*",
    "symfony/polyfill-php70": "*",
    "symfony/polyfill-php56": "*"
    },
    "scripts": {
    "auto-scripts": {
    "cache:clear": "symfony-cmd",
    "assets:install %PUBLIC_DIR%": "symfony-cmd"
    },
    "post-install-cmd": [
    "@auto-scripts"
    ],
    "post-update-cmd": [
    "@auto-scripts"
    ]
    },
    "conflict": {
    "symfony/symfony": "*"
    },
    "extra": {
    "symfony": {
    "allow-contrib": false
    }
    }
    }
    如果有人有一个愚蠢的主意,我会接受的。我已经坚持了很长时间...

    最佳答案

    发生此错误是由于新的XDebug 3.0与Symfony框架不兼容
    有2种可能的方法来修复它:

  • 使用旧版本的XDebug:
  • 强制安装旧版本的xdebug sudo pecl install -f xdebug-2.9.8
  • 通过检查php -v输出
  • 中的XDebug版本,确保扩展处于事件状态
  • 重建SF缓存bin/console cache:clear
  • 临时关闭XDebug并重建缓存(更像解决方法):
  • 使用cli
  • 进入docker容器(或在主机上运行以下命令,具体取决于您的设置)
  • 关闭调试export XDEBUG_MODE=off
  • 重建缓存bin/console cache:clear
  • 再次打开XDebug export XDEBUG_MODE=debug,develop(或任何用作模式的方式)

  • 关注 this issue来了解其他解决方案的最新信息

    关于symfony - fatal error :在安装 Composer 之后,方法class @ anonymous::__ toString()不得引发异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65021444/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com