运行 composer 时 Symfony 的供应商导致自动加载器 psr-4 警告
Symfony's vendors causing autoloader psr-4 warnings when running composer
多年来,每当 运行 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.
我怎样才能摆脱这些由供应商引起的警告?
我的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"
}
}
}
如果代码不在您的控制之下(供应商代码),那么您无法真正解决问题。或者:
- 你升级你的依赖项(这可能很困难和有问题,取决于你的项目,但最终是最好的前进方式)
- 您 将 Composer 降级 到不会引发该警告的版本。这不是推荐的行动方案。你至少会失去性能,并且错过了更高版本的错误修复。
- 您忽略警告,因为警告不是错误,在安装过程中而不是在应用程序运行时显示的警告更是如此。
多年来,每当 运行 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.
我怎样才能摆脱这些由供应商引起的警告?
我的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"
}
}
}
如果代码不在您的控制之下(供应商代码),那么您无法真正解决问题。或者:
- 你升级你的依赖项(这可能很困难和有问题,取决于你的项目,但最终是最好的前进方式)
- 您 将 Composer 降级 到不会引发该警告的版本。这不是推荐的行动方案。你至少会失去性能,并且错过了更高版本的错误修复。
- 您忽略警告,因为警告不是错误,在安装过程中而不是在应用程序运行时显示的警告更是如此。