Home > Blockchain >  Symfony's vendors causing autoloader psr-4 warnings when running composer
Symfony's vendors causing autoloader psr-4 warnings when running composer

Time:04-21

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"
        }
    }
}

CodePudding user response:

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.
  • Related