Search code examples
phpsymfonycomposer-phpautoloadpsr-4

Key autoload is a duplicate in ./composer.json at line 20


I have errors when i did composer update

this is is composer.json

 {
        "name": "trigui/symfony",
        "license": "proprietary",
        "type": "project",
        "autoload": {
            "psr-4": {
                "": "src/"
            },
            "classmap": [
                "app/AppKernel.php",
                "app/AppCache.php"
            ]
        },
      "autoload": {
        "psr-4": {
          "": "src/",
          "VotreNamespace": "chemin/vers/la/bibliotheque"
        },
        "files": [ "app/AppKernel.php" ]
      },    
        "autoload-dev": {
            "psr-4": {
                "Tests\\": "tests/"
            },
            "files": [
                "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
            ]
        },
        "require": {
            "php": ">=5.5.9",
            "doctrine/doctrine-bundle": "^1.6",
            "doctrine/orm": "^2.5",
            "incenteev/composer-parameter-handler": "^2.0",
            "sensio/distribution-bundle": "^5.0.19",
            "sensio/framework-extra-bundle": "^3.0.2",
            "symfony/monolog-bundle": "^3.1.0",
            "symfony/polyfill-apcu": "^1.0",
            "symfony/swiftmailer-bundle": "^2.3.10",
            "symfony/symfony": "3.3.*",
            "twig/twig": "^1.0||^2.0",
            "doctrine/doctrine-fixtures-bundle":"~2.3"
        },
        "require-dev": {
            "sensio/generator-bundle": "^3.0",
            "symfony/phpunit-bridge": "^3.0"
        },
            "branch-alias": null
        }
    }

and this the errors :

Key autoload is a duplicate in ./composer.json at line 20


A non-empty PSR-4 prefix must end with a namespace separator.

Please what is the probleme ?


Solution

  • You have 2 autoload keys at line 5 and 20. There is double brackets closing the end of file at line 48 and 49

    Try this json

    {
        "name": "trigui/symfony",
        "license": "proprietary",
        "type": "project",
        "autoload": {
            "psr-4": {
                "": "src/",
                "VotreNamespace": "chemin/vers/la/bibliotheque"
            },
            "classmap": [
                "app/AppKernel.php",
                "app/AppCache.php"
            ],
            "files": [ "app/AppKernel.php" ]
        },
        "autoload-dev": {
            "psr-4": {
                "Tests\\": "tests/"
            },
            "files": [
                "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
            ]
        },
        "require": {
            "php": ">=5.5.9",
            "doctrine/doctrine-bundle": "^1.6",
            "doctrine/orm": "^2.5",
            "incenteev/composer-parameter-handler": "^2.0",
            "sensio/distribution-bundle": "^5.0.19",
            "sensio/framework-extra-bundle": "^3.0.2",
            "symfony/monolog-bundle": "^3.1.0",
            "symfony/polyfill-apcu": "^1.0",
            "symfony/swiftmailer-bundle": "^2.3.10",
            "symfony/symfony": "3.3.*",
            "twig/twig": "^1.0||^2.0",
            "doctrine/doctrine-fixtures-bundle":"~2.3"
        },
        "require-dev": {
            "sensio/generator-bundle": "^3.0",
            "symfony/phpunit-bridge": "^3.0"
        },
        "branch-alias": null
    }