Symfony的供应商在运行作曲家时会引起自动加载器PSR-4警告

发布于 2025-01-22 12:03:55 字数 3864 浏览 3 评论 0原文

多年来,每当我运行Composer install时,我一直在得到这些警告:

生成优化的自动加载文件(权威)类 sensio \ bundle \ frameworkextrabundle \ tests \ depentencyInjection \ addParamConverterPasStest 位于 ./vendor/sensio/framework-extra-bundle/tests/deppentendentivection/compiler/addparamconverterpasstest.php 不符合PSR-4自动加载标准。跳过。班级 sensio \ bundle \ frameworkextrabundle \ tests \ depentencyindoction \ addexpressionLanguageProvidersPasstest 位于 ./vendor/sensio/framework-extra-bundle/tests/depperencyindoction/compiler/AddexpressionLanguageProvidersPasStest.php 不符合PSR-4自动加载标准。跳过。班级 sensio \ bundle \ frameworkextrabundle \ tests \ request \ paramconverter \ prognnnameconeconconvertertest 位于 ./vendor/sensio/framework-extra-bundle/tests/request/argumentnameconeconvertertest.php 不符合PSR-4自动加载标准。跳过。班级 Doctrine \ bundle \ migrationsBundle \ tests \ depentencyInjection \ doctrinecommandtest 位于 ./vendor/doctrine/doctrine migrations-bundle/tests/command/doctrinecommandtest.php 不符合PSR-4自动加载标准。跳过。

我如何摆脱这些供应商引起警告?

我的composer.json

{
    "name": "...",
    "description": "...",
    "license": "MIT",
    "type": "project",
    "autoload": {
        "psr-4": {
            "AppBundle\\": "src/AppBundle"
        },
        "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/",
            "Features\\": "features/"
        },
        "files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
    },
    "require": {
        "php": "^7.2",
        "aws/aws-sdk-php": "3.178.*",
        "bentools/webpush-bundle": "0.6.*",
        "doctrine/doctrine-bundle": "1.12.*",
        "doctrine/doctrine-migrations-bundle": "1.3.*",
        "doctrine/orm": "2.6.*",
        "endroid/qr-code-bundle": "3.4.*",
        "friendsofsymfony/jsrouting-bundle": "2.4.*",
        "google/apiclient": "2.12.*",
        "google/recaptcha": "1.2.*",
        "incenteev/composer-parameter-handler": "2.1.*",
        "knplabs/knp-time-bundle": "1.15.*",
        "sensio/framework-extra-bundle": "5.2.*",
        "sonata-project/admin-bundle": "3.76.0",
        "sonata-project/core-bundle": "3.20.0",
        "sonata-project/doctrine-orm-admin-bundle": "3.24.*",
        "stripe/stripe-php": "7.102.*",
        "symfony/asset": "4.4.*",
        "symfony/monolog-bundle": "3.4.*",
        "symfony/orm-pack": "2.2.*",
        "symfony/polyfill-apcu": "1.12.*",
        "symfony/swiftmailer-bundle": "3.1.*",
        "symfony/symfony": "4.4.*",
        "symfony/twig-bundle": "4.4.*",
        "symfony/webpack-encore-bundle": "1.14.*",
        "twig/cssinliner-extra": "3.3.*",
        "twig/twig": "2.14.*",
        "ua-parser/uap-php": "3.9.*"
    },
    "require-dev": {
        "behat/behat": "3.7.*",
        "behat/mink": "1.8.*",
        "behat/mink-browserkit-driver": "1.3.*",
        "behat/mink-extension": "2.3.*",
        "behat/mink-goutte-driver": "1.2.1",
        "behat/mink-selenium2-driver": "1.2.0",
        "behat/symfony2-extension": "2.1.*",
        "phpunit/phpunit": "8.5.*",
        "symfony/browser-kit": "4.4.*",
        "symfony/phpunit-bridge": "6.0.*",
        "symfony/test-pack": "1.0.*"
    },
    "scripts": {
        "symfony-scripts": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ],
        "post-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ]
    },
    "config": {
        "platform": {
            "php": "7.2.32"
        },
        "sort-packages": true
    },
    "extra": {
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "3.4-dev"
        }
    }
}

For years, I have been getting these warning whenever I run composer install:

Generating optimized autoload files (authoritative) Class
Sensio\Bundle\FrameworkExtraBundle\Tests\DependencyInjection\AddParamConverterPassTest
located in
./vendor/sensio/framework-extra-bundle/Tests/DependencyInjection/Compiler/AddParamConverterPassTest.php
does not comply with psr-4 autoloading standard. Skipping. Class
Sensio\Bundle\FrameworkExtraBundle\Tests\DependencyInjection\AddExpressionLanguageProvidersPassTest
located in
./vendor/sensio/framework-extra-bundle/Tests/DependencyInjection/Compiler/AddExpressionLanguageProvidersPassTest.php
does not comply with psr-4 autoloading standard. Skipping. Class
Sensio\Bundle\FrameworkExtraBundle\Tests\Request\ParamConverter\ArgumentNameConverterTest
located in
./vendor/sensio/framework-extra-bundle/Tests/Request/ArgumentNameConverterTest.php
does not comply with psr-4 autoloading standard. Skipping. Class
Doctrine\Bundle\MigrationsBundle\Tests\DependencyInjection\DoctrineCommandTest
located in
./vendor/doctrine/doctrine-migrations-bundle/Tests/Command/DoctrineCommandTest.php
does not comply with psr-4 autoloading standard. Skipping.

How could I get rid of these vendor caused warnings?

My composer.json:

{
    "name": "...",
    "description": "...",
    "license": "MIT",
    "type": "project",
    "autoload": {
        "psr-4": {
            "AppBundle\\": "src/AppBundle"
        },
        "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/",
            "Features\\": "features/"
        },
        "files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
    },
    "require": {
        "php": "^7.2",
        "aws/aws-sdk-php": "3.178.*",
        "bentools/webpush-bundle": "0.6.*",
        "doctrine/doctrine-bundle": "1.12.*",
        "doctrine/doctrine-migrations-bundle": "1.3.*",
        "doctrine/orm": "2.6.*",
        "endroid/qr-code-bundle": "3.4.*",
        "friendsofsymfony/jsrouting-bundle": "2.4.*",
        "google/apiclient": "2.12.*",
        "google/recaptcha": "1.2.*",
        "incenteev/composer-parameter-handler": "2.1.*",
        "knplabs/knp-time-bundle": "1.15.*",
        "sensio/framework-extra-bundle": "5.2.*",
        "sonata-project/admin-bundle": "3.76.0",
        "sonata-project/core-bundle": "3.20.0",
        "sonata-project/doctrine-orm-admin-bundle": "3.24.*",
        "stripe/stripe-php": "7.102.*",
        "symfony/asset": "4.4.*",
        "symfony/monolog-bundle": "3.4.*",
        "symfony/orm-pack": "2.2.*",
        "symfony/polyfill-apcu": "1.12.*",
        "symfony/swiftmailer-bundle": "3.1.*",
        "symfony/symfony": "4.4.*",
        "symfony/twig-bundle": "4.4.*",
        "symfony/webpack-encore-bundle": "1.14.*",
        "twig/cssinliner-extra": "3.3.*",
        "twig/twig": "2.14.*",
        "ua-parser/uap-php": "3.9.*"
    },
    "require-dev": {
        "behat/behat": "3.7.*",
        "behat/mink": "1.8.*",
        "behat/mink-browserkit-driver": "1.3.*",
        "behat/mink-extension": "2.3.*",
        "behat/mink-goutte-driver": "1.2.1",
        "behat/mink-selenium2-driver": "1.2.0",
        "behat/symfony2-extension": "2.1.*",
        "phpunit/phpunit": "8.5.*",
        "symfony/browser-kit": "4.4.*",
        "symfony/phpunit-bridge": "6.0.*",
        "symfony/test-pack": "1.0.*"
    },
    "scripts": {
        "symfony-scripts": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ],
        "post-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ]
    },
    "config": {
        "platform": {
            "php": "7.2.32"
        },
        "sort-packages": true
    },
    "extra": {
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "3.4-dev"
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酸甜透明夹心 2025-01-29 12:03:55

如果代码不在您的控制之下(供应商代码),则您将无法真正解决该问题。要么:

  • 升级您的依赖项(这可能很困难且有问题,取决于您的项目,但最终是前进的最佳方法),
  • 降级作曲家 composer to不提高的版本警告。这不是推荐的行动方案。至少您会失去性能,并且错过了以后版本的错误编影。
  • 您忽略了警告,因为警告不是错误,因此在安装过程中而不是在应用程序中显示的警告中偶尔。

If the code is not under your control (vendor code), then you cannot really fix the issue. Either:

  • you upgrade your dependencies (which could be difficult and problematic, depending on your project, but ultimately the best way forward)
  • you downgrade Composer to a version that does not raise that warning. That wouldn't be a recommended course of action. You'd lose in performance at the very least, and miss out on bugfixes of later versions.
  • you ignore the warnings, since warnings are not errors, doubly so on warnings that are shown during installation and not during application rutime.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文